Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Intermediate
Jun 20, 2000

Setting/Resetting Checkboxes with a Single Click

I have a bunch of files on the server that I wanted to be able to select, for example, to delete them or to give them special treatment. Thus, I made a table with their names and a checkbox for each of them. However, I also want to be able to select/deselect _all_ of them with a single click. To do this, I use Javascript.

 
<SCRIPT>
<!--
function SetCheckboxes(value) {
    nb = document.all.item('check').length;
    for(i=0; i<nb; i++) {
        document.all.item('check', i).checked=value;
    }
}
-->
</SCRIPT>

...

<FORM  NAME="ListFiles" METHOD=POST
ACTION='http://www.paisvasco.com/heraldica2/private/borrar.cgi'>
<TABLE border=2 align='center' width='100%'>
<TR><TD><input type='checkbox' id='check' 
name='it_1'></TD><TD>Item
1</TD></TR>
<TR><TD><input type='checkbox' id='check' 
name='it_2'></TD><TD7gt;Item
2</TD></TR>
7lt;TR7gt;<TD align='center' colspan='2'>
    <INPUT type='button' value='Select All'
onclick='SetCheckboxes(true);'>
Olivier Georg
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap