1

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
            }
        ];
1
  • Its not part of your question so I wouldnt put it in the answer section, but jQuery makes tasks like this much easier... $($("table1").find("tr")[0]).find(td)[1].innerText, or something like that Commented Feb 3, 2016 at 14:19

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.