Get a simple example of the value of radio type in JSP form in JS _javascript skill

Source: Internet
Author: User

1, the problem leads to:

We often need to use Ajax in JS to send the request in the background, before we need to collect the required form form parameters, I often this solution, simple and convenient:

Editbasicdataobjectform is the form of the id,data forms of Name1=val1&name2=val2&name3=val3&

var data = $ ("#editBasicDataObjectForm"). Serialize ();

But I got stuck when I needed to get the field value of the radio type in the form once.

After a variety of inspection, finally have the results.

2. Solve the problem:

2.1 editbasicdataobjectform.jsp:

<div calss= "Baselinetype" >

  <div class= "baselinetypelable" >

    <label> Baseline Type:</albel>

  </div>                    

  <div class= "Baselinetypevalue" >

    <input type= "Radio" name= "Baselinetype" id= " BaselineType1 "value=" 1 "/> non-baseline <input type=" Radio "

    name=" Baselinetype "id=" BaselineType2 "value=" 2 "/> Functional baseline

    <input type= "Radio" name= "Baselinetype" id= "BaselineType3" value= "3"/> Assign baseline

  </div>

</div>

2.2 Basicdataobjectoperator.js:

var Baselinetype;

var baselinetypehtmlcol = document.geteementsbyname ("Baselinetype");

for (var i = 0; I < Baselinetypehtmlcol.length; I + +)

{

If (baselinetypehtmlcol[i].checked)

{

baselinetype = baselinetypehtmlcol[i].value;
}

}

.................. 
Baselinetype is the value we need. N_n

Above this JS to get the value of the radio type in the JSP form simple example is a small series to share all the content, hope to give you a reference, but also hope that we support cloud habitat community.

Related Article

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.