Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

select all checkboxes html js

<script language="JavaScript">
function toggle(source) {
  checkboxes = document.getElementsByName('foo');
  for(var i=0, n=checkboxes.length;i<n;i++) {
    checkboxes[i].checked = source.checked;
  }
}
</script>

<input type="checkbox" onClick="toggle(this)" /> Toggle All<br/>

<input type="checkbox" name="foo" value="bar1"> Bar 1<br/>
<input type="checkbox" name="foo" value="bar2"> Bar 2<br/>
<input type="checkbox" name="foo" value="bar3"> Bar 3<br/>
<input type="checkbox" name="foo" value="bar4"> Bar 4<br/>
Comment

html checkbox check all

<script language="JavaScript">
function toggle(source) {
  checkboxes = document.getElementsByName('foo');
  for(var checkbox in checkboxes)
    checkbox.checked = source.checked;
}
</script>

<input type="checkbox" onClick="toggle(this)" /> Toggle All<br/>

<input type="checkbox" name="foo" value="bar1"> Bar 1<br/>
<input type="checkbox" name="foo" value="bar2"> Bar 2<br/>
<input type="checkbox" name="foo" value="bar3"> Bar 3<br/>
<input type="checkbox" name="foo" value="bar4"> Bar 4<br/>
Comment

html checkbox check all

function toggle(source) {
  checkboxes = document.getElementsByName('foo');
  for(var i=0, n=checkboxes.length;i<n;i++) {
    checkboxes[i].checked = source.checked;
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: js loop through object 
Javascript :: remove file from input type file jquery 
Javascript :: how to terminate a program in js 
Javascript :: es6 js slug from string 
Javascript :: check truthy or falsy javascript 
Javascript :: javascript find object by property in array 
Javascript :: js convert string to script 
Javascript :: object to json string android 
Javascript :: vue router push 
Javascript :: remove first and last character from string javascript 
Javascript :: modulo do angular httpclient 
Javascript :: console.log red text on yellow background 
Javascript :: ajax redirect in success 
Javascript :: javascript square root 
Javascript :: for loop array javascript 
Javascript :: day of week javscript 
Javascript :: JavaScript check all checkboxes on page 
Javascript :: check if it is a function javascript 
Javascript :: jquery each 
Javascript :: how to access variables from render() to outside of render() in class react component 
Javascript :: hiding header in a specific screen in react native 
Javascript :: ajax run function after page load 
Javascript :: jQuery get values of selected checkboxes 
Javascript :: style hover js 
Javascript :: javascript add alpha to hex 
Javascript :: angular module with routing cli 
Javascript :: how to know which radio button is selected javascript 
Javascript :: sh 1 nodemon not found heroku 
Javascript :: Add Tailwind CSS to Svelte 
Javascript :: javascript how to print working directory 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =