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

Assign A Value To A Hidden Field When Radio Is Clicked 1

Status
Not open for further replies.

arpan

Programmer
Oct 16, 2002
336
IN
I have the following 4 radio buttons & a hidden field in an HTML Form:

<form name=&quot;form1&quot;>
<input type=hidden name=&quot;txtPrimary&quot;>
<input type=radio name=&quot;pcontact value=&quot;6&quot;>
<input type=radio name=&quot;pcontact value=&quot;136&quot;>
<input type=radio name=&quot;pcontact value=&quot;623&quot;>
<input type=radio name=&quot;pcontact value=&quot;222&quot;>
.........

Please note that the values of the radio buttons are being assigned dynamically (for which I am using ASP) i.e. I am not aware of the values of the radio buttons at design time. Now what I want is when a user clicks one radio button, the hidden field value should be equal to the value of the checked radio button. If the user changes his selection i.e. selects another radio button then the hidden field value should be equal to the value of the newly checked radio button. How do I do this?

Thanks,

Arpan
 
<form name=&quot;form1&quot;>
<input type=hidden name=&quot;txtPrimary&quot;>
<input type=radio name=&quot;pcontact&quot; value=&quot;6&quot; onclick=&quot;document.form1.txtPrimary.value=this.value&quot;>
<input type=radio name=&quot;pcontact&quot; value=&quot;136&quot; onclick=&quot;document.form1.txtPrimary.value=this.value&quot;>
<input type=radio name=&quot;pcontact&quot; value=&quot;623&quot; onclick=&quot;document.form1.txtPrimary.value=this.value&quot;>
<input type=radio name=&quot;pcontact&quot; value=&quot;222&quot; onclick=&quot;document.form1.txtPrimary.value=this.value&quot;>
</form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top