Dynamically Name a Checkbox

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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

Any help would be greatly appreciated.



Posted via http://www.forum4designers.co
View this thread: http://www.forum4designers.com/message109289.htm

Re: Dynamically Name a Checkbox

birdmant wrote:
Quoted text here. Click to load it

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?


Quoted text here. Click to load it

Site Timeline