Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to uncheck list of checkbox when user click "Deselect All" button? 1

Status
Not open for further replies.

joannyk

Programmer
Jan 16, 2001
18
HK
Dear All,

I have the following script which should be executed to unchecked all checkboxes when user click the "Deselect All" button :-

for (count=0; count < 50; count++){
// e_arr is an array contain the suffix of the checkbox
// name

id = e_arr[count];
stat = &quot;document.sub_mem.send_to&quot;+id+&quot;.checked&quot;;
eval(&quot;stat&quot;) = false;
}

However, an error occurred in the eval(&quot;stat&quot;) = false statement. Any suggestion?

Thanks in advance

Joan
 
Hi,

Maybe you should try this:

Code:
id = e_arr[count];       
stat = &quot;document.sub_mem.send_to&quot;+id;
stat.checked = false;

Hope it works :p

Kristof
 
Hi Kristof

Thx for help. After I've tried your codes then no error occurred. However all the checkboxes are still in checked status.

Joan
 
Hi,

I've modified the code a bit and now it should work:
(it did when I tested it :) )

id = e_arr[count];
stat = eval(&quot;document.sub_mem.send_to&quot;+id);
stat.checked = false;

Gtz

kristof
 
if its any help, i use the following function to uncheck all checkboxes on a specific form whos names have a specific prefix...

Code:
function uncheckAll(frm, prefix) {

   l = prefix.length;
   f=document.forms[frm];
   for(i=0;i<f.length;i++) {
   //alert(f.elements[i].name.substr(0,l));
   if(f.elements[i].type==&quot;checkbox&quot; && f.elements[i].name.substr(0,l) == prefix)
      f.elements[i].checked=false;
  }
}

just call it with the form name and the prefix to your checkbox names. any help? ~ ~
 
Thanks Kristof and anorakgirl!! It works now
smile.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top