Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> JavaScript >> Snippet

Check all checkboxes


< html >
< head >
< script >
<!-- Modified By :  Steve Robison, Jr. (stevejr@ce.net) -->
<!-- Begin
var checkflag = "false" ;
function check(field) {
if (checkflag == "false" ) {
for (i = 0; i < field.length; i ++ ) {
field[i].checked = true ; }
checkflag = "true" ;
return "Uncheck All" ; }
else {
for (i = 0; i < field.length; i ++ ) {
field[i].checked = false ; }
checkflag = "false" ;
return "Check All" ; }
}
//  End -->
</ script >

</ head >

< body Background = .. / graphics / grayback.jpg >
< center >< BR >< BR >< BR >
< form name = myform action = "" method = post >
< table >
< tr >< td >
< b > Your Favorite Scripts & Languages </ b >< br >

< input type = checkbox name = list value = "1" > Java < br >
< input type = checkbox name = list value = "2" > JavaScript < br >
< input type = checkbox name = list value = "3" > ASP < br >
< input type = checkbox name = list value = "4" > HTML < br >
< input type = checkbox name = list value = "5" > SQL < br >
< br >                                                    
< input type = button value = "Check All" onClick = "this.value=check(this.form.list)" >
</ td ></ tr >
</ table >
</ form >

</ center >

</ BODY >
</ html >

//Thanks to David Pye for his JavaScript Vault contribution