JSP implementation checkbox's AJAX Transfer value instance _jsp programming

Source: Internet
Author: User

The example of this article describes the AJAX implementation of the checkbox in the JSP transfer value usage. Share to everyone for your reference. The specific analysis is as follows:

Today, I want to use Ajax to all the selected Chekbox values are uploaded to the background to do a deal, but in the background to receive the value of the time, I encountered trouble, thought did not jump so request is no value.

Check it out, find the solution, as follows

Page code:

Copy Code code as follows:
<input type= "checkbox" Name= "Atitle" value= "Historical sites" ><label> Historical monuments </label>
<input type= "checkbox" Name= "Atitle" value= "South Story" ><label> South story </label>
<input type= "checkbox" Name= "Atitle" value= "career Story" ><label> career story </label>
<input type= "checkbox" Name= "Atitle" value= "emotion Story" ><label> Emotion story </label>
<input type= "Chec<a onclick=" check (), return false; "> Submit </A>
<script type= "Text/javascript" >
function Check () {
var chk_value =[];
$ (' input[name=atitle]:checked '). each (function () {
Chk_value.push ($ (this). Val ());
});
chk_value=[historical Sites, Southern stories, career stories, emotional stories, legends puzzle
Chk_value should be like this.
$.ajax ({
Type: "Post",
Url:converturl (' up-ajx.jsp '),
Data: {atitle:$ (' input[name=atitle] '). Val ()},
If this is the case, it can be transmitted normally. But only the first value.
Data: ' atitle= ' +chkvalue,
This seems to be no, now the problem is out here, atitle how to wait for multiple values at the same time.
Up-ajx.jsp is obtained by Request.Form ("Atitle"). The direct use of the JSP can be a normal operation.
DataType: "JSON",
Error:function () {alert (' Error, you do not have a selection option. ');},
Success:function (msg) {
Alert (msg)
}
});
}
</script>

I hope this article will help you with the AJAX program design based on JSP.

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.