Hi guys. I’m a newbie here…
I hope you can help me. I want to place a specific Id name to every item that its created by the add script. And i dont know what to do next
got this code from another tutorial site. I just edited it to be used for my own purpose.
here it is…
var inputs = 0;
function add(){
var table = document.getElementById(‘contacts’);
var tr = document.createElement(‘TR’);
var td1 = document.createElement(‘TD’);
var td2 = document.createElement(‘TD’);
var td3 = document.createElement(‘TD’);
var td4 = document.createElement(‘TD’);
var td5 = document.createElement(‘TD’);
var inp1 = document.createElement(‘INPUT’);
var inp2 = document.createElement(‘INPUT’);
if(inputs>=0){
var img = document.createElement(‘IMG’);
img.setAttribute(‘src’, ‘delete.gif’);
img.onclick = function(){
removeOrder(tr);
}
td5.appendChild(img);
}
inp1.setAttribute(“Name”, “Quantity” +inputs);
inp2.setAttribute(“Name”, “Item”+inputs);
table.appendChild(tr);
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
tr.appendChild(td4);
tr.appendChild(td5);
td1.appendChild(inp1).style.width = 85;
td3.appendChild(inp2).style.width = 485;
td3.appendChild(inp2).value = myform.mymenu.options[myform.mymenu.selectedIndex].value;
inputs++;
}