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.