A simple example of getting the radio type value in the jsp form in js, jspradio

Source: Internet
Author: User

A simple example of getting the radio type value in the jsp form in js, jspradio

1. Question:

We often need to use ajax in js to send requests to the background. Before that, we need to collect the required Form parameters. I often solve this problem, which is simple and easy:

// EditBasicDataObjectForm is the form id. The data format is name1 = val1 & name2 = val2 & name3 = val3 &.....

Var data = $ ("# editBasicDataObjectForm"). serialize ();

However, I am stuck when I need to obtain the radio type field value in the form separately.

After various queries, the results are finally available.

2. Problem Solving:

2.1 In 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"/> function baseline <input type = "radio" name = "baselineType" id = "baselineType3" value = "3"/> baseline allocation </div>

2.2 In 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

The simple example of getting the radio type value in the jsp form in the above js is all the content shared to you by xiaobian. I hope you can give us a reference and support the help house.

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.