954,190 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

string not working

I have the following checkbox on my site but it dosen't work, tried to solve it before but still having trouble.

this is the code from my first page

Do you want to take pets with you?
Yes

This is the code from my second page

IF strPETS = "Y" THEN strSQLLOC = strSQLLOC & " AND fldPETS = 'Y' " ELSE strSQLLOC = strSQLLOC

Please help!!!

squirrelj
Newbie Poster
4 posts since May 2004
Reputation Points: 10
Solved Threads: 0
 
I have the following checkbox on my site but it dosen't work, tried to solve it before but still having trouble. this is the code from my first page

Do you want to take pets with you? Yes
This is the code from my second page IF strPETS = "Y" THEN strSQLLOC = strSQLLOC & " AND fldPETS = 'Y' " ELSE strSQLLOC = strSQLLOC Please help!!!

You're not capturing the value from the HTML form's checkbox. If you have a form with a checkbox name "PETS" then in your ASP script, you have to use Response.Form("PETS") to capture the value "Y" - this is only if the method of the form is "POST" - anyways, try this:

<%
 
IF request.form("PETS") = "Y" THEN 
strSQLLOC = strSQLLOC & " AND fldPETS = 'Y' " 
response.write("YOU CHECKED THE BOX")
ELSE 
strSQLLOC = strSQLLOC
response.write("BOX NOT CHECKED")
end if
 
%>
samaru
a.k.a inscissor
Team Colleague
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18
 

Is a checkbox really sending a string value or is it not a boolen value?

Paladine
Master Poster
Team Colleague
824 posts since Feb 2003
Reputation Points: 211
Solved Threads: 27
 

Actually, it's a string value, and so is everything send via an HTTP GET or POST.

It is up to you, the developer to cast the strings to explicit types.

You must assign the value of the posted form field to your variable, strpets.
Either that, or do this:

IF request.form("PETS") = "Y" THEN strSQLLOC = strSQLLOC & " AND fldPETS = 'Y' "
RobUK
Light Poster
32 posts since Jul 2004
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You