I wonder if someone can help. I have a dynamically created form. Users add rows by clicking 'add row'.
On each row there is a field which represents a date. On the first row it is named "sd[0]", on the second "sd[1]" on the third "sd[3]" and so on.
I also have a master date, called simply "sd". I have an onclick event on this. When the value of this is changed I want all of the other dates also to change.
I have tried the following:
function updateDates(x,y)
{
document.form["sd["+*+"]"].value=x;
}
Where * is a wildcard. This doesn't work. Can anybody suggest a solution? It will be very appreciated.
I imagine a loop will be needed if wildcards aren't an option, however I just can't get my head round it.
I tried the following. It doesn't work but I think it's a move in the right direction. Any ideas?
function updateDates(x,y)
{
var tbody=document.getElementById(tbodyID);
var rowCount=tbody.rows.length;
i=0;
while (i<=rowCount)
{
document.form["sd["+i+"]"].value=x;
i++;
}
}
All of them will probably be or should be in a container element. Loop through the inputs in that container element and set the value to whatever you want.
Great wit and madness are near allied, and fine a line their bounds divide.
Bookmarks