简体   繁体   English

如何读取HTML表格特定行并使用javascript中的值

[英]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.

相关问题 使用 JavaScript:当我编辑特定的 html 表格行时使用模态类。 如何在下拉列表中选择当前值? - Using JavaScript: Using a modal class when i am editing a specific html table row. how to select the current value on a dropdownlist? 如何使用javascript连续获取HTML表格单元格上的Dropdownlist值 - How to get Dropdownlist value on HTML Table Cell in a Row using javascript 如何使用 javascript 在 html 表行中提取嵌套的 json 值 - How to extract nested json value in a html table row using javascript 如何使用JavaScript从HTML表格中获取特定单元格的值 - How to get value from specific cell from a HTML table with JavaScript 如何在一行表格中获取单元格值使用javascript? - How to get a cell value in a row of table use javascript? 如何从数据库表中获取行值以在JavaScript / jQuery中使用它? - How to get a row value from database table to use it in JavaScript / jQuery? 如何使用javascript用复选框替换html表中的真/假值 - How to use javascript to replace true/false value in html table with a checkbox 如何删除html表和数据库中的特定行 - how to delete a specific row in the html table and database 如何使用Javascript / Greasemonkey读取特定的html - How to read specific html using Javascript / Greasemonkey 如何使用JavaScript删除表格中的特定行? - How to delete a specific row in a table using javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM