Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

checked value problem in radio button

Posted on 2006-11-12
4
Medium Priority
?
246 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: 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

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
On September 18, Experts Exchange launched the first installment of the Help Bell, a new feature for Premium Members, Team Accounts, and Qualified Experts. The Help Bell will serve as an additional tool to help teams increase question visibility.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

705 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