I am trying to do a for loop function to validate a set of check boxes. The check boxes are named p_check with a number concatenated to it, which is called v_rows (p_check1, pcheck2, ext.)
I would like to do a for loop without having to access each name separately. There could be many.
An example of my input is:
<input TYPE="checkbox" onclick="ckBox_click(retr_form)" NAME="p_check'||v_rows||'" VALUE="'||v_checkbox_value||'" '|| v_stop_selected_checked ||'>
The v_ variables except for v_rows are set from a database resultset. V_rows count as the loop goes throught the database results.As a side note the data base is Oracle.
Below is what I have, but is not working:
function ckBox_click(theform)
{
for (i=1;i<=3;i++)
{
if (theform.["p_check"+i].checked == true)
{
theform["p_check"+i].value = "on";
}
else
{
theform.["p_check"+i].value = "off";
}
}
}
I would like to do a for loop without having to access each name separately. There could be many.
An example of my input is:
<input TYPE="checkbox" onclick="ckBox_click(retr_form)" NAME="p_check'||v_rows||'" VALUE="'||v_checkbox_value||'" '|| v_stop_selected_checked ||'>
The v_ variables except for v_rows are set from a database resultset. V_rows count as the loop goes throught the database results.As a side note the data base is Oracle.
Below is what I have, but is not working:
function ckBox_click(theform)
{
for (i=1;i<=3;i++)
{
if (theform.["p_check"+i].checked == true)
{
theform["p_check"+i].value = "on";
}
else
{
theform.["p_check"+i].value = "off";
}
}
}