Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Can checkall but can’t invert
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Can checkall but can’t invert

 Post Reply Post Reply
Author
ngaisteve1 View Drop Down
Groupie
Groupie
Avatar

Joined: 26 December 2002
Location: Malaysia
Status: Offline
Points: 169
Post Options Post Options   Thanks (0) Thanks(0)   Quote ngaisteve1 Quote  Post ReplyReply Direct Link To This Post Topic: Can checkall but can’t invert
    Posted: 17 June 2003 at 1:10am
I have a little problem with my check all javascript here. When I click the master checkbox, all the dynamic generated checkbox will be selected and that's good. But, when I click the master checkbox once again to deselect it, those little checkbox didn't deselect except the first one.

The master checkbox code is below:
<input type="checkbox" onClick="SetChecked(1,'chkSample');" >

The Javascript is below:
function SetChecked(val,chkName) {
dml=document.forms[form];
len = dml.elements.length;
var i=0;
for( i=0 ; i<len ; i++) {
if (dml.elements.name==chkName) {
dml.elements.checked=val;
}
}
}

Thanks for the help.
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 17 June 2003 at 1:44am
Here the function I use where field is the name of all the checkboxes

<input type="checkbox" name="chkAll" onClick="checkAll(field);">

<script language="JavaScript">
<!-- Hide from older browsers
//Function to check or uncheck all the checkboxes
function checkAll(field)
{
      if (field.length > 0) {
          for (i = 0; i < field.length; i++)
               field.checked = document.Delete.chkAll.checked ;
          }
      else {
               field.checked = document.Delete.chkAll.checked ;
          }
}
// -->
</script>
Back to Top
abhinav View Drop Down
Groupie
Groupie


Joined: 13 May 2003
Location: India
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote abhinav Quote  Post ReplyReply Direct Link To This Post Posted: 19 June 2003 at 5:16am
wsabstract.com is a good javascript resource. check it out
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.