Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For Loop to access checkbox name

Status
Not open for further replies.

getjbb

MIS
Jun 4, 2003
139
US
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";
}
}
}
 
Hi

getjbb said:
is not working
What do you mean ?

Note that you have extra dots ( . ) in two places between the form name an the subscript. I mean remove the [red]red[/red] one : theform[red].[/red]["p_check"+i].checked .

Assuming that retr_form's value was correctly set before the function call, it works for me. However, I can imagine no reason for changing the [tt]checkbox[/tt]es' [tt]value[/tt] that way.

Feherke.
 
feherke-

What I meant by it did not work is when I the function was called the value was not set to on or off.

I took out the period after the form name (theform) and now it work (Thanks).

I change the value checkbox value because I need to know what the value is further down in my code to pass a variable to an Oracle package.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top