Link to home
Start Free TrialLog in
Avatar of garethtnash
garethtnashFlag for United Kingdom of Great Britain and Northern Ireland

asked on

javascript checkbox select all

Hello, I have a web ford, that has two sets of checkboxes on it, the first has a Select All checkbox, whioch when selected, should only accept the checkboxes of the first batch of checkboxes.

I've only just started putting this together, but am unsure how to fifferentiate between the two groups.

my code is below -

please advise - thank you
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
checked=false;
function checkedAll (newclient) {
	var aa= document.getElementById('frm1');
	 if (checked == false)
          {
           checked = true
          }
        else
          {
          checked = false
          }
	for (var i =0; i < aa.elements.length; i++) 
	{
	 aa.elements[i].checked = checked;
	}
      }
</script>
</head>
<body>
<form id="newclient" name="newclient" method="post" action="afterupload.asp">
  <ul><li><label>Company Name
  <input type="text" name="CompanyName" id="CompanyName" />
  </label></li>
  <li>
    <label>Contact Name
    <input type="text" name="ContactName" id="ContactName" />
    </label>
  </li>
  <li>
    <label>Email Address
    <input type="text" name="email" id="email" />
    </label>
</li>
  <li>
    <label>Phone Number
    <input type="text" name="phone" id="phone" />
    </label>
  </li>
  <li>
    <label>Password
    <input type="text" name="Password" id="Password" />
    </label>
  </li>
  <li>
    <label>Company Address
    <textarea name="address" id="address" cols="45" rows="5"></textarea>
    </label>
</li>
  <li>
    <label>Company Website
    <input name="website" type="text" id="website" value="http://" />
    </label>
  </li>
  <li>
    <label>Company Description
    <textarea name="description" id="description" cols="45" rows="5"></textarea>
    </label>
  </li></ul>
  <ul><br/>
  <li><input type='checkbox' name='checkall' onclick='checkedAll(newclient);'>
  <label>Select All</label>
  </li>
<li><input name="1" type="checkbox" id="1"  value="y"><label>Aberdeenshire</label></li>
<li><input name="2" type="checkbox" id="2"  value="y"><label>Angus</label></li>
<li><input name="3" type="checkbox" id="3"  value="y"><label>Argyll</label></li>
<li><input name="74" type="checkbox" id="74"  value="y"><label>Avon</label></li>
<li><input name="4" type="checkbox" id="4"  value="y"><label>Ayrshire</label></li>
<li><input name="5" type="checkbox" id="5"  value="y"><label>Bedfordshire</label></li>
<ul>
  <li><input type="checkbox" name="AdvertAlerts" id="AdvertAlerts" />
  <label>Turn Off Advert Alerts</label>
</li><li><input type="checkbox" name="ApplicationAlerts" id="ApplicationAlerts" />
  <label>Turn Off Application Alerts</label>
</li>
</ul>
<ul>
<li>
  <label>
  <input type="submit" name="Submit" id="Submit" value="Submit" />
  </label>
</li>
</ul>
</form>
</body>
</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of garethtnash

ASKER

thank you