JS access to the radio button data _javascript tips

Source: Internet
Author: User
Maybe this is a very simple question, but I ignored the radio button while I was learning the program. Lead to a vacancy for his method of data delivery. After whining help to achieve the following about age-selected forms of data acquisition, only in IE test successfully. Test the effect of the program first.
Copy Code code as follows:

<form method= "Post" Name= "Form1" >
<label><input type= "Radio" name= "Radio" value= "1-10 years old" >1-10 years old </label>
<label><input type= "Radio" name= "Radio" value= "11 years old" >11 years old </label>
<label><input type= "Radio" name= "Radio" value= "12-120 years old" >12-120 years old </label>
<input type= "button" onclick= "OK ()" value= "Test selection value" >
</form>

Here is JS fetch data
Copy Code code as follows:

<script language= "javascript" type= "Text/javascript" >
<!--
function ok ()
{
var temp=document.getelementsbyname ("Radio");
for (i=0;i<temp.length;i++) {
Traverse Radio
if (temp[i].checked)
{Alert ("you selected" +temp[i].value);
Gets the value of the radio
Document.form2.textfield.value= "You have chosen" +temp[i].value;
Pass to another form
}
}
}
-->
</script>

Also want data to be passed to another form
Copy Code code as follows:
<form method= "POST" name= "Form2" >
<input type= "text" name= "TextField" >
</form>

Resources
Js:http://www.blueidea.com/tech/web/2006/3567_8.asp
Form:http://www.netvtm.com/w3s/html/html-forms.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.