Hi friends,
I have a doubt about checkboxes, i.e if i am creating checkboxes with the same name, in a loop and i have another checkbox down to the above checkboxes, My problem is that if i select the down checkbox as a result the above checkboxes all to be checked(visible). Is it possible with the javascript.
Please help me my friends.
5 2375 gits 5,390
Recognized Expert Moderator Expert
hi ...
please post the code you have so far ... so that we might have an example to work with ...
kind regards
acoder 16,027
Recognized Expert Moderator MVP
Please remember to provide a meaningful Title for any threads started (see the FAQ entry Use a Good Thread Title).
This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.
MODERATOR
- my $j = 1;
-
while(($u,$cha,$a) = $sth2->fetchrow_array())
-
{
-
print <<HTML;
-
<tr style="color: blue"><td align="right"><input type="checkbox" name="$a" /></td><td align="center"><b>$j.</b></td><td align="center"><b>$cha</b></td><td></td><td align="center"><b>$a</b></td><td align="center">
-
HTML
-
if($u eq $user_name)
-
{
-
print <<HTML;
-
<input name = '$a' type="button" value="EDIT" onclick='disp(this.form,this.name)'>
-
</td><td align="center"><input name = '$a' type="button" value="DELETE" onclick='del(this.form,this.name)'></td></tr>
-
HTML
-
}
-
else
-
{
-
print <<HTML;
-
<input name = '$a' type="button" value="EDIT" onclick='display(this.form,this.name)'>
-
</td><td align="center"><input name = '$a' type="button" value="DELETE" onclick='ddisplay(this.form,this.name)'></td></tr>
-
HTML
-
}
-
$j++;
-
}
-
print <<HTML;
-
</table>
-
</center>
-
<br>
-
<center>
-
<table colspan=3 width="20%">
-
<tr>
-
<td align="center"><input type="checkbox" name="acheck"></td><td align="center"><input type="button" value="Add a New Comment" onclick='addevent(this.form)'></td><td align="center"><input type="button" onclick='next(this.form)' value="Authorize comments"></td>
-
</tr>
-
<tr><td></td></tr><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr>
-
</table>
gits 5,390
Recognized Expert Moderator Expert
hi ...
have a look at the following example:
[HTML]<html>
<html>
<script type="text/javascript">
function check_all(abox) {
var table = document.getElementById('my_table');
var cboxes = table.getElementsByTagName('input');
var l = cboxes.length;
for (var i = 0; i < l; i++) {
var n = cboxes[i];
n.checked = abox.checked;
}
}
</script>
<body>
<table id="my_table">
<tr><td><input type="checkbox" name="cbox"/></td></tr>
<tr><td><input type="checkbox" name="cbox"/></td></tr>
<tr><td><input type="checkbox" name="cbox"/></td></tr>
</table>
check all
<input type="checkbox" name="chk_cbox" onclick="check_all(this);"/>
</body>
</html>[/HTML]
kind regards
acoder 16,027
Recognized Expert Moderator MVP
So, the one named "acheck" should check all the rest.
Add an onclick="checkAll(this.checked)". Now, in the checkAll function, you need to get all the checkboxes. You can get this using document.getElementsByTagName("input"). Then , you will need to check for the type that it's a checkbox. Set the checked property of each to the checked property of the main checkbox.
Edit: gits beat me to it with an example!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bob Bedford |
last post by:
I create checkboxes using datas from a database (with PHP).
I store all values in an array, as I must pass this value like a Form value.
Now, in some cases, when a checkbox is selected, I must...
|
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...
|
by: Travis.Box |
last post by:
I have an MS Access userform with 16 Check Boxes. Each of the
checkboxes has a different option value, which coincides with the Check
Box name (eg. cb01.OptionValue = 1). At the bottom of the...
|
by: .NETn00b |
last post by:
Is this possible?
I need to create a multi-select DataGrid, and I cannot use CheckBoxes.
I want the selected rows to appear highlighted. One possible
work-around that occurred to me was to...
|
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....
| |
by: Frinavale |
last post by:
I'm working on an ASP.NET application using VB.NET for server side code.
I have a GridView listing a bunch of stuff. Above the GridView I have a checkbox named "ChkBx_SelectAll". If this...
|
by: zufie |
last post by:
I have two checkboxes on a form, ChckIBCCP and ChckOtherReferral.
Each checkbox highlights its respective textboxes and combo boxes on
the form.
Many of the highlighted textboxes and combo...
|
by: BibhuAshish |
last post by:
Hi,
I want to check or uncheck a number of checkboxes by clicking an image.
My html code is given below:
<TABLE>
<TR>
<TD>
|
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...
|
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,...
|
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...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |