Click to See Complete Forum and Search --> : ASP If...else Question


kwilliams
02-27-2004, 10:58 AM
I've created this script:
<%
var meeting = String(UploadFormRequest("rbMtg"));
if (meeting = "Y") {
var mtgtime = String(UploadFormRequest("txtTime")) + String(UploadFormRequest("select_ampm"));}

else if (meeting = "N") {
var mtgtime = "---";}
Session("Time") = mtgtime;
%>
<html>
<head>
</head>
<body>
<form>
<input type="radio" name="rbMtg" value="Y" CHECKED>
<input type="radio" name="rbMtg" value="N">
</form>
</body>
</html>
I simply want the Session("Time") to be one value if the radiobutton's value is Y, and another value if the radiobutton's value is N. But this statement keeps inserting the first option, whether the first or second RB is selected. The Insert statement I have is set up to insert Session("Time") into the time column.

Does anyone see something obviously wrong with this setup? Thanks for any help in advance.

buntine
02-27-2004, 11:30 AM
Ok, this is due to a simple JScript syntax error. When testing boolean expressions within an if statement you need to use the = operator twice.
By only using it once you are actually assigning the value "Y" to the variable 'meeting'.


if (meeting == "Y")
{
//statement sequence.
}
else if (meeting == "N")
{
//statement sequence.
}


Regards,
Andrew Buntine.

kwilliams
02-27-2004, 11:34 AM
...and it worked. These little things drive me nuts with JS & ASP. Thanks for pointing out my syntax error, and I'll make sure to remember that for the future. Have a great weekend.

buntine
02-27-2004, 11:39 AM
Thanks, i will try;)

True, one tiny syntax error can be fatal to any program.. Older languages like C and DELPHI are so precise about perfect syntax. Im often debugging for days!

Its all good fun, though.