943,677 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 3787
  • ASP RSS
May 21st, 2004
0

string not working

Expand Post »
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!!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
squirrelj is offline Offline
4 posts
since May 2004
May 24th, 2004
0

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:

ASP Syntax (Toggle Plain Text)
  1. <%
  2.  
  3. IF request.form("PETS") = "Y" THEN
  4. strSQLLOC = strSQLLOC & " AND fldPETS = 'Y' "
  5. response.write("YOU CHECKED THE BOX")
  6. ELSE
  7. strSQLLOC = strSQLLOC
  8. response.write("BOX NOT CHECKED")
  9. end if
  10.  
  11. %>
Team Colleague
Reputation Points: 262
Solved Threads: 18
a.k.a inscissor
samaru is offline Offline
1,227 posts
since Feb 2002
May 24th, 2004
0

Re: string not working

Is a checkbox really sending a string value or is it not a boolen value?
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
Jul 13th, 2004
0

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:
ASP Syntax (Toggle Plain Text)
  1. IF request.form("PETS") = "Y" THEN strSQLLOC = strSQLLOC & " AND fldPETS = 'Y' "
Reputation Points: 10
Solved Threads: 1
Light Poster
RobUK is offline Offline
32 posts
since Jul 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: CursorType help
Next Thread in ASP Forum Timeline: Error message when running ASP email script





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC