Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting value of radio button on submit

Status
Not open for further replies.

JazzMaan

Programmer
Jun 15, 2004
57
US
i have a set with radio buttons.
on submit i need to check if one of them is selected then redirect to a page.

following code is giving error:

<form name="q1" method="post" >
<h4>Please answer the following questions:</h4>

1.What is your Education qualifaction?<br>
<input type="radio" name="r1" value="r1" >Graduction<br>
<input type="radio" name="r1" value="r2" >PostGradution<br>
<input type="radio" name="r1" value="r3" >other<br><br>

2.What is your field of Intrest?<br>

<input type="radio" name="r4" value="r4" >Playing Games<br>
<input type="radio" name="r4" value="r5" >Reading Books<br>
<input type="radio" name="r4" value="r5" >sleeping<br>

<p align="center">
<input type="submit" value="next">

<% if(request.getParameter("r1").equals("r1"))
{
%>
<jsp:forward page="LoginSuccess.jsp" />
<%
}
%>

</form>
 
Maybe you should do it with Javascript prior to submit the form.

Anyway, what error are you getting?

Cheers,
Dian
 
Is any of the options selected?
Did you consider doing this with Javascript?

Cheers,
Dian
 
I would make sure when the page loads to force a radio button to be checked as default. You do this by adding:
Code:
checked="checked"
inside one of the radio buttons. I would do this for both radio button groups.

Also on a side note, you should be closing your input tags. You should be doing:
Code:
<input type="radio" name="r1" value="r1" />Graduction<br/>
<input type="radio" name="r1" value="r2" />PostGradution<br/>
<input type="radio" name="r1" value="r3" />other<br/><br/>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top