Click to See Complete Forum and Search --> : what wrong with this if else


Rattlesnake
08-22-2003, 03:24 AM
hi,
I have form that has 5 radio buttons. Each has the name "Type".
The values for the radio buttons are "Quest","AM","comments","average","count"
I run the following finction on the OnClick() of the Submit button of the form.

My problem is that even if select the "count" or "average" radio buttons , the if elseif statements always defaults to the else part of it . I get the message "I am in last" and always the detailedResult.asp is executed.
What is wrong with my if else if structure????????
Thanks a lot.

function pageSelect ()
{
//alert(document.form1.type.value);
var message="";


for (i = 0; i < document.form1.type.length; i++)
{
if (document.form1.type[i].checked)
message=document.form1.type[i].value
}

if (message=='average')
{
document.form1.action='average.asp'
document.form1.submit();
}

else if (message=='AM')
{
if (message3='99')
{
alert('I am in message=99 ');
document.form1.action='AllAreaMeasured.asp'
document.form1.submit();
}
else
{
alert('I am in message<>99 ');
document.form1.action='detailedResults.asp'
document.form1.submit();
}

}
else if (message=='Count')
{
alert('here value is Count');
document.form1.action='SurveyCount.asp'
document.form1.submit();
}

else
{

alert('I am in last');
document.form1.action='detailedResults.asp'
document.form1.submit();
}



}

Gollum
08-22-2003, 05:10 AM
String comparisons in javascript are case sensitive, so when you compare your radio button's value of 'count' to 'Count', its always going to be false.