[Basic JavaScript control operations]-checkbox operations

Source: Internet
Author: User
Both radio and checkbox have no onchange events, which can be replaced by onclick and custom functions.
However, the checkbox has an onpropertychange event, so you can use onpropertychange to trigger the is selection.

Basic operations of the checkbox:

1. Select an operation ---> onpropertychange, the built-in event processing function of checkbox
2. Select All ---> selectall ();

Detailed description:

1. Select an operation

<Input type = "checkbox" value = "checkbox1" onpropertychange = "javascript: Alert ('checkbox1 was click! '); "> Checkbox1 </>

2. Select All

Function selectall ()
{
VaR isselect = false;
If (document. All. CHX. value = "select all ")
{
Isselect = true;
Document. All. CHX. value = "reselect"
}
Else
{
Isselect = false;
Document. All. CHX. value = "select all"
}

// Var checkboxs = Document. getelementsbyname ("");
VaR checkboxs = Document. form1.elements;
For (VAR I = 0; I <checkboxs. length; I ++)
{
If (checkboxs [I]. type = "checkbox ")
{
Checkboxs [I]. Checked = isselect;
}
}
}

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.