|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
Fixed now.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Pesky checkbox values |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|