<table style="width: 100%; margin-left: 5px;" align="center">
<tr>
<td style="width: 250px; ">
<input type="radio" name="radio1" id="radio1" onclick="chkOut();" /> Create Child Component </td&g开发者_StackOverflowt;
<td>
<input type="radio" name="radio1" id="radio12" onclick="checkOut();"/> Add Component From Another Asset
</td>
</tr>
</table>
var formObj=document.forms[0];
formObj.action="ArcheTypeDevice.in?&status=AddComponent&SelectedText="+txt;
formObj.submit();
function onCallForInterview()
{
var selectedIds;
var count=0;
for (i=0; i<document.frm.check1.length; i++)
{
if (document.frm.check1[i].checked==true)
{
if(count==0){
selectedIds=document.frm.check1[i].value;
count=count+1;
}
else
selectedIds=selectedIds+","+document.frm.check1[i].value;
}
}
alert(selectedIds);
document.frm.action="<%=contextPath%>/SearchCandInfo? action=selectcanforinterview&ids="+selectedIds;
document.frm.submit();
}
You can use this function if you are able to assign unique value to each radio button.
You need to give the input element a value:
<form action="someServletUrl" method="post">
<input type="radio" name="action" value="create" />Create child
<input type="radio" name="action" value="add" />Add component
<input type="submit" />
</form>
In the servlet, just get the selected value the usual way:
String action = request.getParameter("action");
if ("create".equals(action)) {
// "Create child" is selected.
} else if ("add".equals(action)) {
// "Add component" is selected.
}
// ...
No need for nasty JavaScript hacks which ain't going to work on browsers with JavaScript disabled.
精彩评论