Hello,
I am trying to allow users to add elements to a form dynamically. Here is some of my code:
I am trying to allow users to add elements to a form dynamically. Here is some of my code:
Code:
function createNewRow(tbody){
var td,tr;
var cost = quan * 100;
tbody = document.getElementById(tbody);
tr = tbody.insertRow(tbody.rows.length);
//Product Name
td = tr.insertCell(tr.cells.length);
td.innerHTML = "<input type='text name='product_name' value='Product " + row+"'>";
//Product quantity
td = tr.insertCell(tr.cells.length);
td.innerHTML = "<input type='text' name='product_quantity' value=''>";
//Product quantity units
td = tr.insertCell(tr.cells.length);
td.innerHTML = "<input type='text' name='product_units' value='feet'>";
//Product Price
td = tr.insertCell(tr.cells.length);
td.innerHTML = "<input type='text' name='product_units' value='100'>";
//Product Curr
td = tr.insertCell(tr.cells.length);
td.innerHTML = "<input type='text' name='product_units' value='CAD'>";
//Product Total
td = tr.insertCell(tr.cells.length);
td.innerHTML = "<input type='text' name='product_units' value=''>";
row++;
quan++;
}
[\code]
This is not how it is going to work in the end cause I am just testing here to get the code base down. The table that I am adding to is within a form. However, when I post the form to a CGI script to print out all my form elements only the form elements that are present onload show up, not the ones created dynamically with the function above. So any elements that are created by the user pressing a button, do not post. Do I have to explicitly add the elements to the form? If so, how do I do that?
Thanks
P.S.
I hope I was clear on what I am doing.