html - How to write into a table with Javascript? -
<script> function getexperience() { var xp = document.getelementbyid('txt_xp').value; document.getelementbyid("plank").innerhtml = xp/30; } </script>
so here code, , problem seem unable write on data in table id's planl, oakplank, teakplank, , mahoganyplank. thinking may making obvious mistake has done sort of thing before, can't seem catch it. appreciated, , here snippet of table, if helps:
<tr> <td>plank</td> <td id="plankxp">30</td> <td id="plank">0</td> </tr>
edit: didn't realize may pertinent, bad. form used input, after putting alert in see if retrieve xp, functioned correctly:
<form name="experience" id="experience_frm" action="#"> experience: <input type="text" name="xp" id="txt_xp"/> <input type="submit" value="go" onclick="getexperience();"/> </form>
you have used wrong document
method. javascript case sensitive. used:
document.getelementbyid
for getting id="plank"
element. need use:
document.getelementbyid
notice d
(last character) change.
with change, simple example works me:
Comments
Post a Comment