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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with checkbox issue

Status
Not open for further replies.

PushCode

Programmer
Dec 17, 2003
573
US
I need to put checks in checkboxes that are associated with a given record. I'm getting a syntax error, and I'm not sure why. Any help would be appreciated. Here's the line where I'm getting the error:

Code:
response.write  cellstart & "<input type=""checkbox"" name=""opt"" " & if cint(rsOpt(& ""opt_id"" &)) = cint(qOpt(& ""opt_id"" &)) then & " checked=checked" & end if &" value="""& opt_id &""" />" & opt_name & "</td>"

Thanks
 
You need to put single quotes inside double quotes and such like the following:
Code:
response.write  cellstart & "<input type='\'checkbox\'' name='\'opt\''" & if cint(rsOpt(& "'opt_id'" &)) = cint(qOpt(& "'opt_id'" &)) then & " checked='checked'" & end if &" value='"& opt_id &"' />" & opt_name & "</td>"

<.
 
Use single quotes in place of the double quotes except to specify the strings. Using a double quote as escape character just confuses the code.

example
cellstart & "<input type='checkbox' name='op' " &



 
Yeah my code is not right, I have too many nested quotes.
Didn't think about what I was writing, just wrote it.


<.
 
Here:
Code:
response.write  cellstart & "<input type='checkbox' name='opt' " & if cint(rsOpt(& "'opt_id'" &)) = cint(qOpt(& "'opt_id'" &)) then & " checked='checked'" & end if &" value="'& opt_id &'" />" & opt_name & "</td>"
There I had to redeem myself



<.
 
Thanks. I tried your sugestions many different ways, but had no luck so I went a different route.

Here's what I did:

Code:
If opt_id = theOptID Then
							    response.write cellstart & "<input type='checkbox' name='opt' value='" & opt_id & "' checked='checked'>" & opt_name & "</td>"
							Elseif theOptID = "" Then
							    response.write cellstart & "<input type='checkbox' name='opt' value='" & opt_id & "'>" & opt_name & "</td>"
							End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top