Dynamically Name a Checkbox

B

birdmant

I am running a query to return product codes and would like to creata
checkbox for each row returned. I would like to give the checkbox
name using this code so that I can identify it. I'm moving the produc
code to an array but am not successful in setting the name to the cod
value. I've tried arrays and variables to no avail.

Is there a way to do this? This is the piece of code I'm using.

while (!rs.EOF)
{
a[x] = rs.Fields("PROD_CD");
Response.Write("<input type='checkbox' name=a[x] checke
onclick='clickbox(this)'>");
Response.Write("<br>");
rs.MoveNext();
x++;
}


Any help would be greatly appreciated.

To


-
birdman
 
J

Jeff Thies

birdmant said:
I am running a query to return product codes and would like to creata a
checkbox for each row returned. I would like to give the checkbox a
name using this code so that I can identify it. I'm moving the product
code to an array but am not successful in setting the name to the code
value. I've tried arrays and variables to no avail.

Is there a way to do this? This is the piece of code I'm using.

while (!rs.EOF)
{
a[x] = rs.Fields("PROD_CD");
Response.Write("<input type='checkbox' name=a[x] checked
onclick='clickbox(this)'>");
Response.Write("<br>");
rs.MoveNext();
x++;
}

I'm not ASP guy but doesn't that print a[x] instead of the value. .

You'll want to quote the attribute if it contains spaces and make theres
characters it can't start with like digits (I think).

I would do something like this:

Response.Write("<input type='checkbox' name=checkbox_'" + a[x] + "'
checked onclick='clickbox(this)'>");

Iterate through the form collection and look for fields starting with
checkbox_ , and extract the field name.

That may be bad ASP. I don't know how you guys can use ASP, what it
can't do drives me crazy!

PROD_CD is unique isn't it?

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top