SunQuest
           ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old July 24th, 2003, 01:55 AM
Bearette Bearette is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 8 Bearette User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Bearette
Pesky checkbox values

Howdy! I've been good, and looked everywhere for help before posting here...

OK. Building a guestbook. I have a "sign" ASP page, with a checkbox to choose whether or not to hide email address. The VALUE of this checkbox is nicely picked up by the "check your message" page as true/false. When submit is hit on this page, the value is ALWAYS sent to the database as false... regardless of what it was.

Anybody with any ideas?

done.asp
<!--#include file="include/database.inc"-->
<%
...
boolHideEmail = request("hideEmail")
strHideEmail = "'" & boolHideEmail & "'"
If boolHideEmail = "true" Then
boolHideEmail = true
Else
boolHideEmail = false
End If
%>
<html>

<head>
</head>

<body background = "../Images/bg01.jpg" onUnload="refreshParent()">
<form action = "done.asp" method = "post">
...
<input type = "hidden" name = "hideEmail" value = "<% = strHideEmail %>"></input>
<center>Please check the information you entered is correct. If so, press the "Submit" button below,
otherwise click the "Back" button to change your details.
Email:
<% = boolHideEmail %>
...
<input type="submit" name = "nowSubmitForm" value="Submit"></input>
<input type="button" name = "BackBtn" value = "Back" onClick = "javascript:history.back(1);"></input>
</form>
<center>Thankyou for signing our guestbook.<% = boolHideEmail %>

<% If request("nowSubmitForm") <> "" then

dataToDb = "INSERT INTO guestbook (SUBMITDATE, NAME, EMAIL, LOCATION, COMMENTS, HIDEEMAIL) VALUES ('" & strDate & "', '" & strName & "', '" & strEmail & "', '" & strLocation & "', '" & strComment & "', " & boolHideEmail & ")"
con.Execute dataToDb
response.write "<script>window.close();</script>"
End if
%>

</body>
<!--#include file = "include/database_cleanup.inc"-->
</html>

... with all the irrelevant bits removed

Reply With Quote
  #2  
Old July 24th, 2003, 02:18 AM
Shad Shad is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 24 Shad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
First of all

boolHideEmail = request("hideEmail")

should be

boolHideEmail = request.form("hideEmail")

I couldnt see the HTML that for your checkbox, but set to have a value of 1 if it is checked. Then you can do...

Code:
If request.form("hideEmail") = 1 then
    boolHideEmail = True
End if


You don't need to set it to false because if the variable doesn't exist or is empty, it will be false.

Reply With Quote
  #3  
Old July 24th, 2003, 03:06 AM
Bearette Bearette is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 8 Bearette User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Bearette
Hmmm... ok. Well, the html code for the checkbox is on another page, with value set to true, which is why you couldn't see it. But, it really shouldn't matter to what value it is set, as long as I am consistent.
And I tried request.form("hideEmail"), as opposed to just request("hideEmail"), but it made no difference. There are, by the way 4 other values set using request("name_of_var"), which all work fine.
boolHideEmail is holding it's correct value until I hit submit to send it to the database.
Thanks for the suggestions.

Reply With Quote
  #4  
Old July 24th, 2003, 03:08 AM
Bearette Bearette is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 8 Bearette User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Bearette
Hmmm... ok. Well, the html code for the checkbox is on another page, with value set to true, which is why you couldn't see it. But, it really shouldn't matter to what value it is set, as long as I am consistent.
And I tried request.form("hideEmail"), as opposed to just request("hideEmail"), but it made no difference. There are, by the way 4 other values set using request("name_of_var"), which all work fine.
boolHideEmail is holding it's correct value until I hit submit to send it to the database.
Thanks for the suggestions.

Reply With Quote
  #5  
Old July 24th, 2003, 01:46 PM
Bearette Bearette is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 8 Bearette User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Bearette
Fixed now.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Pesky checkbox values


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway