[Javascript] createElements(): new row in table
Michael Borchers
borchers at tridem.de
Wed Sep 28 04:47:12 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_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);
document.getElementById('trProducts').appendChild(mycurrent_cell);
//----------------------------------------------------------------------
// works fine, but...
//----------------------------------------------------------------------
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) ;
document.getElementById('tableProducts').appendChild(mycurrent_row);
//----------------------------------------------------------------------
// won't work:(
//----------------------------------------------------------------------
} // for
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20050928/56805c65/attachment.htm>
More information about the Javascript
mailing list