campanal
asked on
check if radio is checked
hi experts,
i have a question for you:
how can i check if one of the radio button that I have in the page is checked?
sth like:
if (radio is cheked) return true
else alert("no radio checked" return false
i have a question for you:
how can i check if one of the radio button that I have in the page is checked?
sth like:
if (radio is cheked) return true
else alert("no radio checked" return false
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And if you do want to do it in an asp page after submit then it returns it's value if checked, check it like this:
If Request.Form("radiobuttonN ame") <> "" Then
'True
Else
'False
End If
Be sure the name and value are set or else it still won't work.
You can also have more radiobuttons with the same name, the checked one gives his value then. For example both names are name="gender" and the value of each is: value="Male" and value="Female"
Then you can see with Request.Form("gender") what value is chosen..
If Request.Form("radiobuttonN
'True
Else
'False
End If
Be sure the name and value are set or else it still won't work.
You can also have more radiobuttons with the same name, the checked one gives his value then. For example both names are name="gender" and the value of each is: value="Male" and value="Female"
Then you can see with Request.Form("gender") what value is chosen..
ASKER
great sajuks you are the best!!
Glad to help you out. Thanks for the points and grade.
but if you make a function you could do this
function IsRadioButtonChecked( )
{
alert( document.formname.radiobut
return document.formname.radiobut
}
or you could pass the function the radio button you want to use
function IsRadioButtonChecked( objRadioButton )
{
alert( objRadioButton.checked )
return objRadioButton.checked;
}
so you could do this
<input type="button" name="btnTest" value="Click Me To See If A Radio Button Is Checked" onclick="IsRadioButtonChec
or
<input type="button" name="btnTest" value="Click Me To See If A Radio Button Is Checked" onclick="IsRadioButtonChec