javascript - Struggling with DOM elements -


i have html table in .aspx page looks follows:

  <table id="quotationslisttable" class="quotetbl" width="100%" border="1">   <tr>     <th></th>     <th>ref</th>     <th>name</th>     <th>arrival</th>     <th>time</th>     <th>departure</th>     <th>time</th>     <th>curr</th>     <th>sale</th>     <th>cost</th>   </tr>   <tr>     <td><input type="checkbox" name="chk"/></td>     <td> 1 </td>     <td><input type="text" style="width: 50px" /> </td>     <td><input type="text" style="width: 150px"/> </td>     <td> <input type="text" style="width: 50px"/> </td>     <td> <input type="text" style="width: 50px"/> </td>     <td> <input type="text" style="width: 50px"/> </td>     <td> <input type="text" style="width: 50px"/> </td>     <td> <input type="text" style="width: 50px"/> </td>     <td> <input type="text" style="width: 50px"/> </td>   </tr>   </table> 

i have javascript function deleting rows in table, calling element id "quotationslisttable".

the javascript function stays in separate .js file follows:

deleteallrows('quotationslisttable');  function deleteallrows(tableid) {     try {         var table = document.getelementbyid(tableid);         var rowcount = table.rows.length;          (var = 1; < rowcount; i++) {             var row = table.rows[i];             var chkbox = row.cells[0].childnodes[0];             table.deleterow(i);             rowcount--;             i--;           }     } catch (e) {         alert(e);     } } 

the problem @ hand js function cannot retrieve table id, error message thrown 'undefined'.

it's document.getelementbyid note small d

var table = document.getelementbyid(tableid); 

https://developer.mozilla.org/en-us/docs/dom/document.getelementbyid


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -