[英]How to read a HTML table specific row and use the value in javascript
I have a HTML table created and I want to read the value in cell and use it in a javascript.. Can anyone please suggest how to do this... 我创建了一个HTML表,我想读取单元格中的值并在javascript中使用它。有人可以建议如何执行此操作...
<table id="table1">
<tr id="1">
<td> pue </td>
<td> 2.86 </td>
</tr>
</table>
<script>
var PUIDValue = document.getElementById("pue").value;
var chartData1 = [
{
"category": "Evaluation",
"excelent": 20,
"good": 20,
"average": 20,
"poor": 20,
"bad": 20,
"limit": 78,
"full": 100,
"bullet": PUIDValue
}
];
I am not sure about the size and which data you expect to use, but you could convert your table to a javascript array and then get the values from there. 我不确定要使用的大小和数据,但是可以将表转换为javascript数组,然后从中获取值。
Here is an example: Convert html table to array in javascript 这是一个示例: 将html表转换为javascript中的数组
mainTr = document.getElementById('1'),
firstTd = mainTr.getElementsByTagName('td')[0]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.