admin管理员组

文章数量:1401673

Well basically I have 3 check boxes. Each of them has a boolean which gets turned to true when a button is clicked and the box is checked.

However is it possible to do an action, when unchecking a check box without having to hit another button to trigger an event first.

so as example: I select check box 1 & 2. => I hit start button -> boolean for check box 1 & 2 gets set to true. => I uncheck check box 2 -> trigger event

Well basically I have 3 check boxes. Each of them has a boolean which gets turned to true when a button is clicked and the box is checked.

However is it possible to do an action, when unchecking a check box without having to hit another button to trigger an event first.

so as example: I select check box 1 & 2. => I hit start button -> boolean for check box 1 & 2 gets set to true. => I uncheck check box 2 -> trigger event

Share Improve this question edited Aug 2, 2020 at 19:26 Martijn Pieters 1.1m321 gold badges4.2k silver badges3.4k bronze badges asked Mar 24, 2013 at 13:56 Firefox333Firefox333 936 silver badges18 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 5

Use the onchange attribute of the input tag which activates some javascript; eg:

HTML:

<input type = "checkbox" id = "checkbox_id" onchange = "change()" value = "foo">

JavaScript:

function change()
{
//do something
}

本文标签: javascriptHow to do an action when unchecking a checkboxStack Overflow