Read td values and display total with php or javascript -
i remake question hoping better understood. i'm working on table.php file structured below:
<table> <tr> <td class="a" name="id">field1</td> <td class="b" name="title">field2</td> <td class="c" name="adder">field3</td> <td class="d" name="addend">field4</td> <td class="e" name="sum">field5</td> </tr> </table>
what want read given values of field3 , field4, make addition calculation of both numbers, , display result in field5 php or javascript. have tried this:
<script> var x = document.getelementbyclassname("a"); var y = document.getelementbyclassname("b"); var z = x+y; document.write('z').innerhtml = c; </script>
or
<script> var = document.getelementbyclassname("a").innerhtml; var b = document.getelementbyclassname("b").innerhtml; var c = a+b; document.write("c").innerhtml = c; </script>
...but none of them working. new ideas?
with jquery :
var tot1 = parseint($('.a').text()); var tot2 = parseint($('.b').text()); var tot3 = parseint(tot1+tot2); $('.c').text(tot3);
regards
Comments
Post a Comment