I have an asp.net gridview (not sure if that even matters) which displays an undetermined number of rows. Each row has an input field (textbox) for a date. I need the ability to allow the user to enter a date in the input field in the first row, then click a link that triggers a javascript call that will populate each remaining row's date field with the value that the user entered in the first row. What I've already done is programmatically add an attribute to each row called 'index'. Which is numbered sequentially starting from zero. I was thinking this would be an easy way to populate the remaining input fields, where their index value was not equal to zero.
I just need help with the looping through the rows and population of the fields. I think I'm close but I'm not sure.
Here's the JS:
And the link that calls the JS:
...which passes the hardcoded name of the gridview, and the dynamic name of the first row's date field.
Any help is greatly appreciated.
I just need help with the looping through the rows and population of the fields. I think I'm close but I'm not sure.
Here's the JS:
Code:
function fillAll(theGrid, rowIdx)
{
var tbl = document.getElementById(theGrid);
for(var i = 1; i< tbl.rows.length;i++)
{
if (document.getElementById('index').value != 0 )
{
document.getElementById('<%=txtRequestDate.ClientID %>').value = document.getElementById(rowIdx).value;
}
}
}
Code:
javascript:fillAll('gvCheckout', '" +((GridViewRow)Container).FindControl("txtRequestDate").ClientID + "')
Any help is greatly appreciated.