Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

when i click on one checkbox check all checkboxes

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;
    }
}
Comment

when i click on one checkbox check all checkboxes

<p><input onClick="setAllCheckboxes('actors', this);" type="checkbox" />All of them</p>
<div id="actors">
    <p><input type="checkbox" name="kevin" />Spacey, Kevin</p>
    <p><input type="checkbox" name="colin" />Firth, Colin</p>
    <p><input type="checkbox" name="scarlett" />Johansson, Scarlett</p>
</div>
Comment

PREVIOUS NEXT
Code Example
Javascript :: react function being called every minute 
Javascript :: download jquery 
Javascript :: javascript intl.numberformat reais 
Javascript :: hover con js 
Javascript :: object deep copy 
Javascript :: js array of objects get a specific key from all objects 
Javascript :: determine if array has duplicates lodash 
Javascript :: check if two rectangles overlap javascript canvas 
Javascript :: react input number validation 
Javascript :: leaflet each layer 
Javascript :: javascript queryselector child element 
Javascript :: unity javascript 
Javascript :: javascript long integer 
Javascript :: how to find last element of array react 
Javascript :: sequelize init connection set up nodejs node 
Javascript :: pyramid javascript 
Javascript :: moment get start of week in datetime 
Javascript :: Javascript random password generator Exampe 
Javascript :: syntax function 
Javascript :: nodejs buffer.from base64 
Javascript :: nested object javascript 
Javascript :: PayloadTooLargeError express 
Javascript :: loading image in react js 
Javascript :: usenavigate in react 
Javascript :: react-native razorpay 
Javascript :: copy object array javascript 
Javascript :: javascript define global variable 
Javascript :: difference between the `.append()` method and the `.appendChild()` method 
Javascript :: Group array of strings by first letter 
Javascript :: settimeout javascript for loop 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =