Results 1 to 4 of 4
-
08-29-2014, 09:27 PM #1is a threadkiller
- Join Date
- Jan 2002
- Location
- Ohio
- Posts
- 3,155
[Javascript] Check all checkboxes problems
I'm working on a permissions system using checkboxes and found some code online and modified it slightly for my use. I'm not a javascript expert or anything and I dont understand what the script is doing.
For the most part the script works correctly, but sometimes you have to click the "full" permissions box for it to take effect and toggle the related boxes. Its not a huge issue, but it could be quite annoying.
Here is the javascript thats in use...
Code:function togglePerms(gname){ var checkboxes = document.getElementsByName(gname); var button = document.getElementById('toggle'); if(button.value == 'select') { for (var i in checkboxes) { checkboxes[i].checked = 'FALSE'; } button.value = 'deselect' } else { for (var i in checkboxes) { checkboxes[i].checked = ''; } button.value = 'select'; } }
Code:<td class="tablecat title" align="center">Admins</td> <td class="td_alt2" align="center"><input class="double" type="checkbox" name="admins" value="full" onClick="togglePerms('admins')" id="toggle"></td> <td class="td_alt2" align="center"><input class="double" type="checkbox" name="admins" value="view" checked ></td> <td class="td_alt2" align="center"><input class="double" type="checkbox" name="admins" value="add" checked ></td> <td class="td_alt2" align="center"><input class="double" type="checkbox" name="admins" value="edit" checked ></td> <td class="td_alt2" align="center"><input class="double" type="checkbox" name="admins" value="delete" checked ></td> <td class="td_alt2" align="left">None</td> <td class="td_alt2" align="center"></td>
http://2thextreme.org/weathercms/test.html
Thanks in advance for ideas and tips.Don't like what I say? Ignore me.
-
08-30-2014, 04:38 PM #2Junior Guru Wannabe
- Join Date
- Oct 2008
- Posts
- 80
Hi MGCJerry,
Are you looking to do something else then what the script currently does?
It does exactly what you think it is doing. It selects or deselects all of the check boxes in that row, when the "Full" check box is select or deselected.Morgan Klaif
Business Manager / System Administrator / IT
MorganKlaif28 [at] comcast [dot] net
-
09-13-2014, 12:29 AM #3Junior Guru Wannabe
- Join Date
- Sep 2014
- Location
- Oregon
- Posts
- 33
I agree with what is said above, it seems that this script does select all the inputs once you click full. If you would like to change this to automatically select all change where it says
Code:<td class="td_alt2" align="center"><input class="double" type="checkbox" name="admins" value="full" onClick="togglePerms('admins')" id="toggle"></td>
Code:<td class="td_alt2" align="center"><input class="double" type="checkbox" name="admins" value="full" onLoad="togglePerms('admins')" id="toggle"></td>
Code:<td class="td_alt2" align="center"><input class="double" type="checkbox" name="admins" value="full" onLoad="setTimeout=function(){togglePerms('admins');},300)" id="toggle"></td>
<< Signature to be set up in profile >>Last edited by Postbox; 09-13-2014 at 05:11 AM.
-
09-15-2014, 03:22 AM #4WHT Addict
- Join Date
- Sep 2007
- Posts
- 120
EmailHosting.com
http://www.emailhosting.com
Similar Threads
-
javascript validation of checkboxes
By szarwell in forum Programming DiscussionReplies: 0Last Post: 11-09-2005, 03:10 PM -
Javascript: Check all checkboxes within a div element?
By Pheaton in forum Programming DiscussionReplies: 2Last Post: 07-21-2005, 06:03 PM -
javascript check all boxes
By sikkhost in forum Programming DiscussionReplies: 21Last Post: 05-25-2005, 07:01 PM -
help with javascript toggle all checkboxes code.
By Nullified in forum Programming DiscussionReplies: 8Last Post: 07-07-2004, 10:33 AM -
JavaScript help needed! (Involves textfields and checkboxes)
By sachit64 in forum Programming DiscussionReplies: 7Last Post: 11-17-2003, 02:55 PM