Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Client Side Scripting
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 09-15-2005, 04:01 PM
  #1
mastahkaz
Adept (Level 5)
 
Join Date: Feb 2002
Posts: 47
iTrader: (0)
mastahkaz is on a distinguished road
Check All Checkboxes

I was wondering if there's a way to have an unlimited amount of groups of checkboxes, each with their own "master" checkbox at the top which when checked would check all of the other boxes in that coresponding group.

Now the catch is, ALL the checkboxes need to have the same name and ID. So the script cant really say, "when this master box is checked also check all other checkboxes with the name or ID so and so...".

They all also need to be part of the same form.

Anyone have any ideas?

Heres what the base HTML would look like:

Code:
<form>
<input type="checkbox" name="masterBox"> (master checkbox)<br>
<input type="checkbox" name="itmBox" id="itmBox" value="random"> 1<br>
<input type="checkbox" name="itmBox" id="itmBox" value="random"> 2<br>
<input type="checkbox" name="itmBox" id="itmBox" value="random"> 3<br>
<input type="checkbox" name="itmBox" id="itmBox" value="random"> 4<br>
<hr>
<input type="checkbox" name="masterBox"> (master checkbox)<br>
<input type="checkbox" name="itmBox" id="itmBox" value="random"> 1<br>
<input type="checkbox" name="itmBox" id="itmBox" value="random"> 2<br>
<input type="checkbox" name="itmBox" id="itmBox" value="random"> 3<br>
<input type="checkbox" name="itmBox" id="itmBox" value="random"> 4<br>
<hr>
<input type="checkbox" name="masterBox"> (master checkbox)<br>
<input type="checkbox" name="itmBox" id="itmBox" value="random"> 1<br>
<input type="checkbox" name="itmBox" id="itmBox" value="random"> 2<br>
<input type="checkbox" name="itmBox" id="itmBox" value="random"> 3<br>
<input type="checkbox" name="itmBox" id="itmBox" value="random"> 4<br>
<hr>
<input type="checkbox" name="masterBox"> (master checkbox)<br>
<input type="checkbox" name="itmBox" id="itmBox" value="random"> 1<br>
<input type="checkbox" name="itmBox" id="itmBox" value="random"> 2<br>
<input type="checkbox" name="itmBox" id="itmBox" value="random"> 3<br>
<input type="checkbox" name="itmBox" id="itmBox" value="random"> 4<br>
<hr>
</form>
mastahkaz is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-18-2005, 08:30 AM
  #2
Kalessin
Soldier (Level 11)
 
Kalessin's Avatar
 
Join Date: Jan 2004
Location: Northampton, UK
Posts: 112
iTrader: (0)
Kalessin is on a distinguished road
The fact that all your checkboxes have the same name and id is a problem and I can't work out why you've done it that way. I reckon that, as far as the DOM is concerned, they are all pretty much the same checkbox. How are you hoping to retrieve input when your form is submitted?

Anyway, I'd imagine you could hack your way around the problem by applying a CSS style to each group of checkboxes then using that to uniquely identify each group.
Kalessin is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-18-2005, 01:01 PM
  #3
Hiei
Myrmidon (Level 12)
 
Hiei's Avatar
 
Join Date: Jun 2004
Location: MI
Posts: 185
iTrader: (0)
Hiei is on a distinguished road
you could just, after naming your individual checboxes 1,2,3 and so on then write a script saying when "master checkbox" is checked check 1,2,3 and all. thats the only way i can see that if there is another way i would really be interested in the how that worked
__________________
if ($post == written)
{ print "this is my signiture"}
Hiei is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-20-2005, 03:37 AM
  #4
maskd
Swordman (Level 9)
 
maskd's Avatar
 
Join Date: Sep 2005
Location: NSW, Australia
Posts: 88
iTrader: (0)
maskd is an unknown quantity at this point
Code:
<html>
<head>
<title>Check All boxes</title>

<script language="Javascript">
<!--
function checkAll(obj)
{
  for (i=0;i<obj.length; i++) {
    obj[i].checked = true;
  }
}
</script>

</head>

<body>

<form name="checkForm">
<input type="checkbox" name="masterBox" onclick="checkAll(document.checkForm.itmBox)"> (master checkbox)<br>
<input type="checkbox" name="itmBox" id="itmBox" value="1"> 1<br>
<input type="checkbox" name="itmBox" id="itmBox" value="2"> 2<br>
<input type="checkbox" name="itmBox" id="itmBox" value="3"> 3<br>
<input type="checkbox" name="itmBox" id="itmBox" value="4"> 4<br>
</form>

</body>

</html>
maskd is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart
 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 10:06 AM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.