Hi
I try develop my order form and I need a help with adding/copy records in the table.
I have table with 3 columns: one contains list, second contains text field, third button.
The aim is to choose item from list, than provide quantity and press add button to add next record/row (formula needs to copy the drop down list, quantity field must be EMPTY) plus add button next to row.
Now, copied record displays previous values.
More over I need Remove button in the row.
If any have other solution (based on check boxes add and remove button) let me know. Many thanks Eva
Below part of my code:
<script type="text/JavaScript">
function addRow(r){
var root = r.parentNode;//the root
var allRows = root.getElementsByTagName('tr');//the rows' collection
var cRow = allRows[0].cloneNode(true)//the clone of the 1st row
var cInp = cRow.getElementsByTagName('input');//the inputs' collection of the 1st row
for(var i=0;i<cInp.length;i++){//changes the inputs' names (indexes the names)
cInp[i].setAttribute('name',cInp[i].getAttribute('name')+'_'+(allRows.length+1))
}
var cSel = cRow.getElementsByTagName('select')[0];
cSel.setAttribute('name',cSel.getAttribute('name')+'_'+(allRows.length+1));//change the selecet's name
root.appendChild(cRow);//appends the cloned row as a new row
}
function shownames(){
var allInp=document.getElementsByTagName('input');
for(var i=0;i<allInp.length;i++){
alert(allInp[i].name)
}
}
</script>
Bookmarks