Hi,
I have the following function. Everything works except the assignment of the onclick event. I need to pass 3 arguments dynamically to the function call like this: rmdep(this, i, d). How do I go about this?
Thanks for your time,
Csanád
I have the following function. Everything works except the assignment of the onclick event. I need to pass 3 arguments dynamically to the function call like this: rmdep(this, i, d). How do I go about this?
Thanks for your time,
Csanád
Code:
function rmdep(what,i,d)
{ // i is the index of current Item
// d is the index of current Dependant Item
var deps=document.getElementById('dep_'+i).value; // deps is the number of Dependant Items for current Item
if (d==deps) // remove the last Dependant Item
{
deps--;
document.getElementById('dep_'+i).value=deps;
}
else // remove Dependant Item from the middle of list; renumber following Dependant Items
{
var q=d+1;
var depup;
for (q; q<=deps; q++)
{
depup=document.getElementById(i+'_'+q);
depup.setAttribute('name','f'+i+'_'+d);
depup.setAttribute('id',i+'_'+d);
depup.previousSibling.previousSibling.firstChild.nodeValue='Dependant Item ['+d+']';
depup.nextSibling.nextSibling.[b]onclick='rmdep(this,i,d); return false'[/b];
depup.nextSibling.nextSibling.setAttribute('id','r_'+i+'_'+d);
d++;
}
deps--;
document.getElementById('dep_'+i).value=deps;
}
while (what && what.tagName!='DIV') { what=what.parentNode; }
if (what) what.parentNode.removeChild(what);
}