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!

Trouble handling checkboxes

Status
Not open for further replies.

PushCode

Programmer
Dec 17, 2003
573
US
My form page has some dynamically listed checkboxes, all with the same name. I'm trying to insert any values that are checked into a SQL db. The problem is that it is only inserting the first of the checked boxes gets inserted. I don't get any errors.

Here's my checkbox code:
Code:
response.write  cellstart & "<input type=""checkbox"" name=""opt"" value="""& opt_id &""" />" & opt_name & "</td>"

Here's the relevent action page code:
Code:
opt = Request.Form("opt")
aryopt = Split(opt, ",")
set con = server.createObject("ADODB.Connection")
con.open(strServerConnection)
'insert options
For x = 0 to Ubound(aryopt)
	Dim sqlOpt
	sqlOpt = "INSERT INTO ecom_option_match (prod_id, opt_id) VALUES ('"&prod_id&"', '"&aryopt(x)&"')"
	con.execute(sqlOpt)
Next
Any ideas as to why it's only inserting the first checked value?

Thanks!
 
Are you looping your code that response.write(s) the checkboxes??

If not, you will only have one checkbox show

<.
 
Yes I'm looping that code. The form page is working fine. All the checkboxes show up as expected.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top