Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

checked value problem in radio button

Posted on 2006-11-12
4
Medium Priority
?
248 Views
Last Modified: 2010-04-01
i give radio button name for all;i can't give different name for all rado buttons. if i check one radio button it should fetch me checked
employeeNo value;

<%

String test[] =request.getParameterValues("test");

System.out.println("kk");
if(test != null && test.length > 0)
{
for(int i=0;i<test.length;i++)
      {

      }
}
%>

<html>
<head>
<script language="javascript">
<!--

function getSelected(radioObj){
  for(var i = 0; i < radioObj.length; i++){
    if(radioObj[i].checked){
        document.forms[0].test[i].value=radioObj[i].value;
        alert(document.forms[0].test[i].value)
    }
  }

}

//-->
</script>
</head>
<body>
<form action="example.jsp">
<input type="radio" name="test" value="a" onclick="getSelected(this.form.test);">A<br>
<input type="hidden" name="employeeNo0" value="1">

<input type="radio" name="test" value="b" onclick="getSelected(this.form.test);">B<br>
<input type="hidden" name="employeeNo1" value="2">

<input type="radio" name="test" value="c" onclick="getSelected(this.form.test);">C<br>
<input type="hidden" name="employeeNo2" value="3">

<input type="radio" name="test" value="d" onclick="getSelected(this.form.test);">D<br>
<input type="hidden" name="employeeNo3" value="4">

<input type="submit" value="submit" >

</form>
</body>
</html>
0
Comment
Question by:chaitu chaitu
  • 2
4 Comments
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 17927892
i want corresponding employeeNo value in jsp;
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17932373
your bean would hold the "selected" radion button value and you will have to get it from the getTest( ) in the  bean.
0
 
LVL 9

Accepted Solution

by:
ftaco96 earned 2000 total points
ID: 17933299
Try this...

String test =request.getParameter("test");
String employeeNo = request.getParameter("employeeNo" + test);


and the HTML would look like this...

<input type="radio" name="test" value="a" onclick="getSelected(this.form.test);">A<br>
<input type="hidden" name="employeeNoa" value="1">

<input type="radio" name="test" value="b" onclick="getSelected(this.form.test);">B<br>
<input type="hidden" name="employeeNob" value="2">

<input type="radio" name="test" value="c" onclick="getSelected(this.form.test);">C<br>
<input type="hidden" name="employeeNoc" value="3">

<input type="radio" name="test" value="d" onclick="getSelected(this.form.test);">D<br>
<input type="hidden" name="employeeNod" value="4">


--- OR ---

Why not just do this?

<input type="radio" name="employeeNo" value="1" onclick="...">A<br>

<input type="radio" name="employeeNo" value="2" onclick="...">B<br>

<input type="radio" name="employeeNo" value="3" onclick="...">C<br>

<input type="radio" name="employeeNo" value="4" onclick="...">D<br>


and the JSP would look like this...

String employeeNo = request.getParameter("employeeNo");
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
Integration Management Part 2
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question