Anyone know what's wrong with this? I have some Classic ASP code that checks for the value of a checkbox, like so:
<!-- HTML page: page1.asp --->
<input id="useBilling" name="useBilling" value="Y" type="checkbox" />
And in my code page (let's call it page2.asp):
' code
useBilling = Request.Form("useBilling")
' useBilling should be "Y" here
If useBilling = "Y" Then
' using billing info
Else
' not using billing info
End If
The problem is that sometimes, even when I check the checkbox, it's passing an empty string to Request.Form and the wrong code is being executed. I've placed a few Response.Write calls to trace it (this is VBScript, remember) and sometimes it says the value is "Y" but later when I check the value in the conditional, it's empty.
Been wracking my brain trying to figure out why the hell this isn't working, because everything seems to be right, just Request.Form sometimes picks up the value and sometimes doesn't, even when it's checked. Hell, sometimes I'll test it by commenting out the execution code and it will say the value is "Y" then when I uncomment the executing code, it's mysteriously empty again.
EDIT: Weirdly enough, if I include a Response.End tag in the conditional, it will operate as I expect, but when I remove the Response.End it no longer finds the checkbox's value (returns empty) even though a minute ago (with Response.End uncommented) it output a test message that says "Okay, the checkbox was checked". With Response.End commented out, it says "The checkbox wasn't checked".
I even try outputting the value of the checkbox (which should be "Y" if it's checked, and nothing if it's not). And, sure enough if the conditional includes Response.End it will output "Y" and if I remove Response.End, it's empty.