473,466 Members | 1,354 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Selecting multiple checkboxes with a single checkbox.

Hi all,

I have a form that generates a dynamic number of rows from a value
passed in via querystring. I have a one static row in my form with a
"master" checkbox that I have deemed "Select All:". I want to be able
to select all and deselect all the other checkboxes beneath it in the
column by clicking on it. I've gotten it partially working. I can
click the "master" checkbox and it will set the .checked property of
all the others to true. BUT how do I reverse the process and turn them
all off? Here is my funcion:

function selectAllInstall()
{
var frm;
frm = document.frm;

if (frm.chkCheckAllInstall.checked = true)
{
for (var i = 0; i < <%=dtlQty%>; i++)
{
frm.chkInstallReq[i].checked = true;
}
}

if (frm.chkCheckAllInstall.checked = false)
{
for (var i = 0; i < <%=dtlQty%>; i++)
{
frm.chkInstallReq[i].checked = false;
}
}
}

HTML for the Main Checkbox:
<td class="mnuHdr"><input type="checkbox" name="chkCheckAllInstall"
onClick="selectAllInstall();"></td>

Any ideas or suggestions would be greatly appreciated.

Thanks.
Jul 20 '05 #1
1 17358
Oz
Here is a simple solution:

<script language="javascript">
function checkAll(master){
var checked = master.checked;
var col = document.getElementsByTagName("INPUT");
for (var i=0;i<col.length;i++) {
col[i].checked= checked;
}
}
</script>

Master: <input type="checkbox" onclick="checkAll(this)"><br>
Slave1:<input type="checkbox" ><br>
Slave2:<input type="checkbox" ><br>

regards
Mike


"Eric" <ek***@unumprovident.com> wrote in message
news:11**************************@posting.google.c om...
Hi all,

I have a form that generates a dynamic number of rows from a value
passed in via querystring. I have a one static row in my form with a
"master" checkbox that I have deemed "Select All:". I want to be able
to select all and deselect all the other checkboxes beneath it in the
column by clicking on it. I've gotten it partially working. I can
click the "master" checkbox and it will set the .checked property of
all the others to true. BUT how do I reverse the process and turn them
all off? Here is my funcion:

function selectAllInstall()
{
var frm;
frm = document.frm;

if (frm.chkCheckAllInstall.checked = true)
{
for (var i = 0; i < <%=dtlQty%>; i++)
{
frm.chkInstallReq[i].checked = true;
}
}

if (frm.chkCheckAllInstall.checked = false)
{
for (var i = 0; i < <%=dtlQty%>; i++)
{
frm.chkInstallReq[i].checked = false;
}
}
}

HTML for the Main Checkbox:
<td class="mnuHdr"><input type="checkbox" name="chkCheckAllInstall"
onClick="selectAllInstall();"></td>

Any ideas or suggestions would be greatly appreciated.

Thanks.

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jez | last post by:
Hi, I have created the following functions to select and deselect checkboxes in a form ... function check(checkbox) { for (i = 0; i < checkbox.length; i++) { checkbox.checked = true; }...
8
by: Ralph Freshour | last post by:
I have multiple checkbox's created with an array name because I have many on the same web page - their names are like: frm_chk_delete frm_chk_delete frm_chk_delete frm_chk_delete etc. Here...
5
by: @(none) | last post by:
I have a page which is a set of CheckBoxes generated daily and thus the number of Checkboxes changes each day. What I want to do is allow the user to select one or more checkboxes and the push a...
1
by: sneha123 | last post by:
There will be some 20 questions and for each question there will be 4 choices.what i want to do is to select multiple answers by clicking the checkbox. i m using asp.net,vb.net pls help me we...
1
by: Bob Loveshade | last post by:
I am looking for an example that shows how to select and highlight multiple rows in a DataGrid. My DataGrid is part of a Web User Control which is contained in an ASPX page. I haven't been...
6
by: jeffsnox | last post by:
Hi, I have multiple checkboxes on the same form as follows: <input type='checkbox' name='cbtype' value='1'> <input type='checkbox' name='cbtype' value='2'> <input type='checkbox'...
5
by: purush2purush | last post by:
HI All.... cud any one provide me the code for : Selecting mulitiple checkboxes and sending mail when clicked on submit button. The checkboxes are retrived from the Mysql...
0
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td...
1
by: infernodeep | last post by:
Hi, I have a dynamically generated form, and each listing contains a checkbox named 'del'. The users checks the 'del' checkbox next to each listing they wish to delete, and click the submit...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.