473,238 Members | 1,625 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,238 software developers and data experts.

how to check/uncheck a number of checkboxes by clicking an image

Hi,

I want to check or uncheck a number of checkboxes by clicking an image.

My html code is given below:
[HTML]

<TABLE>
<TR>
<TD>
<div id = "checkdiv" >
<img src = "/images/check.jpg" />
</div>
</TD>
</TR>
<TR>
<TD>
<input type = "checkbox" name = "del">
</TD>
</TR>
<TR>
<TD>
<input type = "checkbox" name = "del">
</TD>
</TR>
</TABLE>

[/HTML]

Now if i click image or div all the checkboxes should be checked and again if i click that image or div all the checkboxes should be unchecked.
Jul 24 '08 #1
3 3344
maminx
77
i think you must make another event.
For example, onclick for check the checkbox and another event for uncheck the chekbox..


But hope this can usefull...

first, change your "a" tag with this

[HTML]<a href="#" onclick="javascript:setBox();" ><img src="/images/check.jpg"></a>[/HTML]

second. Better use a unique name for checkbox.
The first checkbox may named "del1", and second checbox goes to "del2".
Of course this is depends with your need

than after the body, make the script

[HTML]<script type="text/javascript">
function setBox() {
var form = document.forms[0];
form.del1.checked=true;
form.del2.checked=true;
}
</script>[/HTML]

and as i said, to uncheck the checbox, i think you need another event,,

thanks..

kind regards,
maminx
Jul 24 '08 #2
gits
5,390 Expert Mod 4TB
the javascript: part in the following line is never needed:

Expand|Select|Wrap|Line Numbers
  1. onclick="javascript:setBox();"
the following:

Expand|Select|Wrap|Line Numbers
  1. onclick="setBox();"
is always enough ...

kind regards
Jul 24 '08 #3
acoder
16,027 Expert Mod 8TB
Make one function which checks/unchecks all checkboxes and pass it a parameter to determine whether it should be checked or not, e.g.
Expand|Select|Wrap|Line Numbers
  1. function checkUncheckBoxes(check) {
  2.   var chk = document.getElementsByName(chckboxname);
  3.   for (i = 0; i< chk.length; i++) {
  4.     chk[i].checked = check;
  5.   }
  6. }
Jul 29 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: pw | last post by:
Hi, I need to create a function in javascript to check or uncheck all checkboxes in a form. From what I understand, I can do this either by specifying the name of the check box fields such as: ...
10
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....
4
by: lemat | last post by:
Hi, I use a radio button form in which users can select a color by clicking on a image. I would like this image to change to another one when it's chosen. (image with a "Chosen" Stamp in the...
4
by: chengsi | last post by:
Hi, I have a "continuous" subform which is linked to a table which has a checkbox field. I would like to create a Check All/Uncheck All checkbox control that both checks and disables the...
12
by: swebster | last post by:
I need to zero in on a specific section of my jsp form during a hide to uncheck the checkboxes in that section. Currently, anything I try either unchecks all checkboxes on the form or doesn't work...
3
by: Ryanfromscotland | last post by:
Hey there everyone, this is my first post so be nice :-) I have wrote quite a bit so the actual question is written out at the end if you want to skip on and see if you can answer it without the rest...
13
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...
1
by: Anuj | 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...
14
by: dragon52 | last post by:
Hi Everyone, Not sure the following is possible to do. The standard MS Access user interface has checkboxes on a number of menu pages, such as Tools/Options/View. I have been asked to find a...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.