I'm using the following code for a checkbox that when clicked, either
checks or unchecks a group of checkboxes on a form. The code works
fine, except when there is only one checkbox in the group in which case
the check all checkbox doesn't work at all.
The code working with three checkboxes in a group is as follows, but
remove two of the three and you will see the code stops working:
<script language="javas cript" type="text/javascript">
function checkAll( control, cbGroupName )
{
var cbGroup = control.form.el ements[cbGroupName], i = 0, cb;
while( cb = cbGroup[i++] )
{
cb.checked = control.checked ;
}
}
</script>
<form>
Check all
<input type="checkbox" onclick="checkA ll( this,'select[]' );" >
<br><br>
<input type="checkbox" name="select[]" value="234">
<input type="checkbox" name="select[]" value="235">
<input type="checkbox" name="select[]" value="236">
</form>
If anyone can offer some insight into what is causing the problem I
would be very grateful.
Limbo 2 2210 li*****@surffas t.com wrote: I'm using the following code for a checkbox that when clicked, either checks or unchecks a group of checkboxes on a form. The code works fine, except when there is only one checkbox in the group in which case the check all checkbox doesn't work at all.
The code working with three checkboxes in a group is as follows, but remove two of the three and you will see the code stops working:
<script language="javas cript" type="text/javascript">
Language is deprecated.
function checkAll( control, cbGroupName ) { var cbGroup = control.form.el ements[cbGroupName], i = 0, cb; while( cb = cbGroup[i++] )
When there is only one checkbox, cbGroup is not a collection and there
is no cbGroup[i].
{ cb.checked = control.checked ; } } </script>
<form> Check all <input type="checkbox" onclick="checkA ll( this,'select[]' );" > <br><br> <input type="checkbox" name="select[]" value="234"> <input type="checkbox" name="select[]" value="235"> <input type="checkbox" name="select[]" value="236"> </form>
If anyone can offer some insight into what is causing the problem I would be very grateful.
Here's a modified version:
function checkAll( control, cbGroupName )
{
var cbGroup = control.form.el ements[cbGroupName],
i = cbGroup.length,
cb;
if ('number' == typeof i){
while( cb = cbGroup[i++] ) {
cb.checked = control.checked ;
}
} else {
cbGroup.checked = control.checked ;
}
}
--
Rob
RobG wrote: li*****@surffas t.com wrote: <script language="javas cript" type="text/javascript">
Language is deprecated.
So we are using a deprecated means of communication? ;-)
SCNR
PointedEars This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Banta |
last post by:
Hi,
I have created a 12 month calendar where each day has a check box
whereby the user can indicate if that day is available or not
available for a certain event. The calendar is 'drawn' in a single
form rather than 12 separate forms.
If the checkbox contained in each day within each month has a unique
name such as 1August2003, 2August2003, etc, is there a way in
Javascript where I could have a button by each month where the user...
|
by: Edward |
last post by:
The following html / javascript code produces a simple form with check
boxes. There is also a checkbox that 'checks all' form checkboxes
hotmail style:
<html>
<head>
<title></title>
</head>
<body>
<form name="myform" action=test.php method=post>
|
by: jimi_xyz |
last post by:
Sorry if this isn't the correct group, i don't think there is a group
for straight HTML. I am trying to create a type of search engine. There
are two radio buttons at the top, in the middle there is a text box,
with the search button next to it, and at the bottom there are four
check boxes. When the form loads one of the two radio buttons are
selected as the default, what i want is when someone clicks on one of
the four checkboxes, one of...
|
by: sianan |
last post by:
I tried to use the following example, to add a checkbox column to a
DataGrid in an ASP.NET application:
http://www.codeproject.com/aspnet/datagridcheckbox.asp
For some reason, I simply CAN'T get the example to work. I created the
following two classes, provided with the example:
*-*-**-*-*-*-*-*-*-*-*-*-**-*-*-*-*-CheckBoxColumn
Class:-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-**-*-*-*
|
by: rn5a |
last post by:
All the rows in a DataGrid, including the Header, are accompanied with
a CheckBox. I want that when the CheckBox in the Header is checked,
then all the CheckBoxes should automatically get checked. I set the
AutoPostBack property of the CheckBox in the Header to True & am
invoking a sub named 'CheckAllRows' on the CheckedChanged event of this
CheckBox. The CheckBox in the Header exists within the HeaderTemplate
of a TemplateColumn in the...
| |
by: morellik |
last post by:
Dear all,
I have a program that creates dinamically a web page.
In the page I have the following function to check how many checkbox
are checked.
function tarInfo(info) {
var i=0;
var c=0;
var l=document.forms.selected_files.length;
alert(l);
|
by: it2051229 |
last post by:
Well i'm having a problem with the compatibility of javascript and PHP multiple delete check box.. i used a javascript for the "CHECK ALL BOXES" just like yahoo mail.. so my input is something like this "<input type='checkbox' name='checkbox' value='1'><input type='checkbox' name='checkbox' value='2'>" and the check all boxes function worked but it doesnt work with my PHP code where it is something like this :
$checked = $_POST;
for($i=0;...
|
by: rjoseph |
last post by:
HI Guys
I have a simple check box form (using GET as the method) with a list of 10 different UK counties. I have validated the form so that users have to select no more and no less than 5 UK counties.
The validation works fine. However, when the form is posted to my next page (myresults.asp), I need the values of the options to output the following in my url, no matter what UK counties they choose or what order they select them in:
I...
|
by: PhpCool |
last post by:
Hi, since sometime I'm stuck in a problem where I want to check or
uncheck all the checkboxes. If I'm choosing name for the checkbox
array as 'chkbx_ary' then I'm able to check/uncheck all the checkboxes
(code pasted below). But if name of the checkbox array is
'chkbx_ary' then it's failing. I want the name to be 'chkbx_ary'
because I want to access this array at server side.
Though one may not require to see php part but I'm still pasting...
|
by: ghjk |
last post by:
my php page has 7 check boxes. I stored checked values to database and retrive as binary values. This is the result array
Array ( => 0 => 1 => 0 => 1 => 0 => 0 => 1 )
1 means checked. I want to display these results in check boxes. This is my code. But it doesn't work
<tr><td><input value="1" type="checkbox" id="1" name="check" <?php if ($array==1) echo "value=checked";?>/>Fasting 6 hours</td>
<td><input value="2"...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |