amesome
amesome

Reputation: 57

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...

<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
            }
        ];

Upvotes: 1

Views: 299

Answers (2)

Luca Giardina
Luca Giardina

Reputation: 518

mainTr = document.getElementById('1'),
firstTd = mainTr.getElementsByTagName('td')[0]

Upvotes: 1

Willian Dallastella
Willian Dallastella

Reputation: 36

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.

Here is an example: Convert html table to array in javascript

Upvotes: 1

Related Questions