Confirm when displaying the contents of an array, always take a comma-delimited solution

Source: Internet
Author: User

The key to the problem is to convert the array to a string, with the elements of each array as a string, plus a newline carriage return, before displaying the confirm:

The background color in the code is the key point

<script type= "Text/javascript" >
$ (function () {
Gets the value of the selected check box
var checkedarray = new Array ();//Set the value of the selected checkbox
The number of Var count;//already selected
$ (' #btn_submit '). Click (function () {
checkedarray.length=0;
count=0;
$ (' [name=item]:checkbox:checked '). each (function () {
Checkedarray.push ($ (this). Val ());
count++;
});
if (checkedarray.length==0) {
Alert ("Check one at least.");
Return
}
Confirm (the value of the selected check box: "+" \ n "+checkedarray.join (" \ n ")+" \ n "+" check box selected: "+count);
});
})
</script>

Confirm when displaying the contents of an array, always take a comma-delimited solution

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.