Select all checkboxes and fire event? |
Select all checkboxes and fire event? |
tk=lm2408 |
Feb 20 2017, 03:58 AM
Post
#1
|
Newbie Group: Members Posts: 19 Joined: 31-January 17 Member No.: 26,289 |
I have a bunch of checkboxes, I also have a select all link that will select all of the checkboxes on the page. This all works fine. The problem is that I need to call their function as soon as they are selected. The script I have for this is:
CODE <script type="text/javascript"> function setAllCheckboxes(divId, sourceCheckbox) { divElement = document.getElementById(divId); inputElements = divElement.getElementsByTagName('input'); for (i = 0; i < inputElements.length; i++) { if (inputElements[i].type != 'checkbox') continue; inputElements[i].checked = sourceCheckbox.checked; } } </script> This is the html for the checkboxes: CODE <li><input type="checkbox" class="focusable" onfocus="parentFocus(event)" onblur="parentBlur(event)" value="my data"><label>label text</label></li> I am happy with this so far except for it not firing the event on selection. Thank you Greg This post has been edited by tk=lm2408: Feb 20 2017, 04:05 AM |
tk=lm2408 |
Feb 20 2017, 10:16 PM
Post
#2
|
Newbie Group: Members Posts: 19 Joined: 31-January 17 Member No.: 26,289 |
Woo hoo! Got it working. Thank you Christian
|
Lo-Fi Version | Time is now: 18th March 2024 - 08:48 PM |