Method _ javascript tips-js tutorial

Source: Internet
Author: User
This article mainly introduces how to implement and determine whether a check box is selected for javascript. It involves the javascript operation checkbox technique and is of great practical value, you can refer to the examples in this article to describe how to select all js programs and determine whether there is a check box. Share it with you for your reference. The specific implementation method is as follows:

The Code is as follows:

Function actionEvent (methodname ){
Var form = document. forms [0];
If (validateIsSelect (form. all, form. productids )){
Form. action =' ';
Form. submit ();
} Else {
Alert ("select the record to be operated ");
}
}

Function allselect (allobj, items ){
Var state = allobj. checked;
If (items. length ){
For (var I = 0; I If (! Items [I]. disabled) items [I]. checked = state;
}
} Else {
If (! Items [I]. disabled) items. checked = state;
}
}
/*
* Determine whether a record is selected
*/
Function validateIsSelect (allobj, items ){
Var state = allobj. checked;
If (items. length ){
For (var I = 0; I If (items [I]. checked) return true;
}
} Else {
If (items. checked) return true;
}
Return false;
}

The Code is as follows:

Select All

The Code is as follows:

I hope this article will help you design javascript programs.

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.