Discussion:
onchange event in radio button
(too old to reply)
Matt
2004-01-23 03:36:54 UTC
Permalink
I have radio buttons on a form, and when the user makes the selection, it
will trigger the event and send the form to the web server and print the
selected value. In Case 1, I just use submit button, without any event
handling, and it works fine.

However, in Case 2, which is what I am trying to do, it has the problem that
even when the user clicks the button, it won't show the value automatically.
But wait until user selects another choice.

Any ideas? Thanks!

----------------------------------------------------------------------------
-----
Case 1:
<%
If (Request.Form("submitbutton") = "submit here") Then
Response.Write(Request.Form("radiogroup"))
End If
%>

<html>
<body>
<form action="radiobuttontest.asp" name="myform" method="post">
<P>Choice 1<input type="radio" name="radiogroup" value="choice1">
<P>Choice 2<input type="radio" name="radiogroup" value="choice2">
<P>Choice 3<input type="radio" name="radiogroup" value="choice3">
<P><input type="submit" name="submitbutton" value = "submit here">
</form>
</body>
</html>

----------------------------------------------------------------------------
-----
Case 2:

<%
Response.Write(Request.Form("radiogroup"))
%>

<html>
<body>
<form action="radiobuttontest1.asp" name="myform" method="post">
<P>Choice 1<input type="radio" name="radiogroup" value="choice1"
onchange="document.myform.submit()">
<P>Choice 2<input type="radio" name="radiogroup" value="choice2"
onchange="document.myform.submit()">
<P>Choice 3<input type="radio" name="radiogroup" value="choice3"
onchange="document.myform.submit()">
</form>
</body>
</html>
Steve Fulton
2004-01-23 13:21:01 UTC
Permalink
Post by Matt
I have radio buttons on a form, and when the user makes the selection, it
will trigger the event and send the form to the web server and print the
selected value. In Case 1, I just use submit button, without any event
handling, and it works fine.
However, in Case 2, which is what I am trying to do, it has the problem that
even when the user clicks the button, it won't show the value automatically.
But wait until user selects another choice.
According to MS, radio buttons don't support the onchange event.

INPUT type=radio Element
http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/input_radio.asp

onchange Event
http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onchange.asp
--
Steve

No, no, you're not thinking, you're just being logical. -Niels Bohr
Continue reading on narkive:
Loading...