JS Simple way to get the radio button values in the form _javascript tips

Source: Internet
Author: User

The example in this article describes the method of JS simple to get the radio button value in the form. Share to everyone for your reference, specific as follows:

The HTML section is as follows:

<form>
<tr bgcolor= "#FFFFFF" > <td width= "height=" "rowspan="
  3 "align=" Center "valign=" Middle "
  bordercolor=" #999999 "><span class=" STYLE1 "> Fallback type:</span></td> <td
  " 360 "align=" center "valign=" Middle "bordercolor=" #999999 "><input type=" Radio "name=" Returntag "
  value="-1 " checked= "Checked" >
  Reporting Department </td>
</tr>
<tr bgcolor= "#FFFFFF" >
  <td align= " Center "valign=" middle "bordercolor=" "#999999" ><input type= "Radio" name= "Returntag" value= "
  1" > Provincial Network Bidding Center </td>
</tr>
<tr bgcolor= "#FFFFFF" >
  <td align= "center" valign= "Middle" Bordercolor= "#999999" ><input
  type= "Radio" name= "Returntag" value= "2" > National Network Bidding center </td>
</ Tr></form1>

The JS code is as follows:

function GetValue ()
{
//Gets the radio button value for
  (Var i=0;i<form1.returntag.length;i++)
  {
   if ( form1.returntag[i].checked)
   {
    var returntagvalue=form1.returntag[i].value//Here is the radio button value
    }
  }
}

More readers interested in JavaScript-related content can view the site topics: "JavaScript Search Algorithm Skills Summary", "JavaScript data structure and algorithm skills summary", "JavaScript traversal algorithm and Skills summary", " A summary of JSON manipulation techniques in JavaScript, a summary of JavaScript switching effects and techniques, a summary of JavaScript animation effects and techniques, JavaScript errors and debugging tips, and a summary of JavaScript mathematical operational usage

I hope this article will help you with JavaScript programming.

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.