AW: [Javascript] createElements(): new row in table
Michael Borchers
borchers at tridem.de
Wed Sep 28 05:58:10 CDT 2005
> >>
<http://michaelborchers.net/js/dom2.php> http://michaelborchers.net/js/dom2.php
so far so good, adding a single cell in a row with an id works fine,
but i can't add a complete row.
please see the script which was supposed to do both,
what's wrong?
function addOrdersNumRows()
{
var ordersNumRowsAdded = document.getElementById("orders_num_rows_added").value;
for(o=0;o<ordersNumRowsAdded;o++)
{
mycurrent_row=document.createElement("TR");
mycurrent_cell=document.createElement("TD");
mySelect = document.createElement("select");
mySelect.setAttribute("name","products_id[1][products_id]");
theOption=document.createElement("OPTION");
theText=document.createTextNode("Produkte");
theOption.appendChild(theText);
theOption.setAttribute("value","1");
mySelect.appendChild(theOption);
mycurrent_cell.appendChild(mySelect);
mycurrent_row.appendChild(mycurrent_cell) ;
var tbody = document.getElementById("tableProducts").tBodies[0];
} // for
}
<<<<
found the solution: you HAVE to use the tbody tag:
var tbody = document.getElementById("tableProducts").tBodies[0];
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20050928/f0af5ed3/attachment.htm>
More information about the Javascript
mailing list