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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio button usage in struts

Status
Not open for further replies.

makdu

Programmer
Aug 15, 2009
22
0
0
KW
I am trying to develop a web page.In the webpage, i have two radio button. I need to make visible some text fields and labels when one radio button is selected and make other fields invisible. Here is what i have coded


<tr>
<td width="10%"> </td>
<td width="10%" colspan="2" align="center">
<html:radio property="regradio" VALUE="viamob"/>
Register via mobile number</td>
</tr>
<tr>
<td width="10%" colspan="2" align="center">
<html:radio property="regradio" VALUE="viaAA" />
Register via AA System number </td>
</tr>

<tr>
<tr>
<td width="10%"> </td> <td width="10%"><font face="Verdana" size="2"><bean:message key="label.login.username" /></font></td>
<td width="10%">
<html:text property='newusername' style="display" /></td>
<td width="10%"><font face="Verdana" size="2"><bean:message key="label.login.username"/></font></td>
<td width="10%">
<html:text property='newusername' style="display" /></td>
</tr>

<tr>
<td width="10%"> </td> <td width="10%"><font face="Verdana" size="2"><bean:message key="label.register.mobileno"/></font></td>
<td width="10%">
<html:text property='newmobno' /></td>
<td width="10%"><font face="Verdana" size="2"><bean:message key="label.register.emailid"/></font></td>
<td width="10%">
<html:text property='emailId' /></td>
</tr>
<tr>

<html:button property='go' value="Go" onClick="javascript:fnCheck(this.form)"/>
</tr>



Here is the script part.

<Script language='Javascript'>
function fnCheck(frm)
{
if(frm.regradio.value=="viaAA")
{
frm.newusername.style.display="none";
}
if(frm.regradio.value=="viamob")
{
frm.newusername.style.display="block";
}
}
</script>

But no field is getting visible/invisible when the selection of radio button is different. Please help. I have searched in net , but didnt yield any result
 
This is a pure Javascript question, you shouldp post in in the Javascript forum.

Anyway, you're invoking the javascript code when pressing the button, but not when clicking the readiobuttons

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top