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:

http://jsfiddle.net/wqzaq/


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -