I am so close, but am banging my head to get it right. I wish to add and remove rows to a column as defined by two connected dropdown menus. The code almost works perfectly, but when I remove a row, my second dropdown doesn't display correct. Any thoughts? Also, even more important, any (hopfully constructive) critisim about my code. I am new, and am sure it is not the prettiest in the world.
Thank you in advance, and thank you to those who have gotten me as far as I am!
function add_item(obj1,obj2)
{
index=obj2.selectedIndex;
if (!obj2.set){
obj2.set=new Array();
for (abc=0;abc<obj2.options.length;abc++){
obj2.set[abc]=obj2.options[abc].text;
obj2.ary=new Array();
}
}
obj2.ary[index]=document.getElementById('TRClone').cloneNode(true);
document.getElementById('TBdy1').appendChild(obj2.ary[index]);
obj2.ary[index].sel=obj2;
obj2.ary[index].getElementsByTagName('TD')[0].firstChild.data=obj1.value;
obj2.ary[index].getElementsByTagName('TD')[1].firstChild.data=obj2.value;
}
function remove_item(obj){
obj=obj.parentNode.parentNode;
for (abc=0;abc<obj.sel.length;abc++){
if (obj.sel.set[abc].match(obj.getElementsByTagName('TD')[0].firstChild.data)){
obj.sel.options[abc].text=obj.sel.set[abc];
}
}
// obj.sel.selectedIndex=0;
document.getElementById('TBdy1').removeChild(obj);
}
In regards to function, one select option is used to limit choices, and a second select option is used to pinpoint the choice. The user can then "add" as many selected option as desired, and once "added", they can input a quanity or delete it. My next step which I haven't even started is to use php server side to act on the inputs.
Bookmarks