The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> Select all checkboxes and fire event?
tk=lm2408
post 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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
 
Reply to this topicStart new topic
Replies
tk=lm2408
post 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 smile.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 08:53 PM