DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   ASP (http://www.daniweb.com/forums/forum62.html)
-   -   string not working (http://www.daniweb.com/forums/thread6219.html)

squirrelj May 21st, 2004 12:15 pm
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

<P>Do you want to take pets with you?
<INPUT type=CHECKBOX name = "PETS" value = "Y">Yes<br>

This is the code from my second page

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

Please help!!!

samaru May 24th, 2004 3:34 am
Re: string not working
 
Quote:

Originally Posted by squirrelj
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

<P>Do you want to take pets with you?
<INPUT type=CHECKBOX name = "PETS" value = "Y">Yes<br>

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
 
%>

Paladine May 24th, 2004 3:52 am
Re: string not working
 
Is a checkbox really sending a string value or is it not a boolen value?

RobUK Jul 13th, 2004 1:10 pm
Re: string not working
 
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' "


All times are GMT -4. The time now is 2:34 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC