473,221 Members | 1,967 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,221 software developers and data experts.

Javascript to check checkboxes?

Hi all. I'm wondering if there's a way to have checkboxes become
selected without clicking the mouse. Perhaps if you rollover the
checkboxes, they could toggle checked and unchecked? Or perhaps you
could click-and-hold and then drag across a series of checkboxes to
select them?

Please let me know,
Sincerely,
Paul Rubin
pr****@equilter.com
Jul 20 '05 #1
5 1758
"Paul Rubin" <pr****@equilter.com> wrote in message
news:f9**************************@posting.google.c om...
Hi all. I'm wondering if there's a way to have checkboxes become
selected without clicking the mouse. Perhaps if you rollover the
checkboxes, they could toggle checked and unchecked? Or perhaps you
could click-and-hold and then drag across a series of checkboxes to
select them?

Please let me know,
Sincerely,
Paul Rubin
pr****@equilter.com

Like the following? Watch for word-wrap.

<html>
<head>
<title>checkme.htm</title>
<script language="javascript" type="text/javascript">
<!--
function mouser() {
var form = document.forms[0];
if (form.box1.checked) {
form.box1.checked = false;
} else {
form.box1.checked = true;
}
}
// -->
</script>
</head>
<body>
<form>
<input type="checkbox" name="box1" value="1" onmouseover="mouser()">
</form>
</body>
</html>
Jul 20 '05 #2
McKirahan wrote:

function mouser() {
var form = document.forms[0];
if (form.box1.checked) {
form.box1.checked = false;
} else {
form.box1.checked = true;
}
}


Or:

function mouser() {
var theBox = document.forms[0].elements['box1'];
theBox.checked = !theBox.checked;
}

Depending on which syntax you prefer...
JW

Jul 20 '05 #3
Thanks for your kind reply. How about if there are a whole bunch of
checkboxes, with names, p.1, p.2, p.3, etc ???

I hope this can be incorporated!
Sincerely,
Paul Rubin
pr****@equilter.com

"McKirahan" <Ne**@McKirahan.com> wrote in message news:<yZJHb.486016$Dw6.1425226@attbi_s02>...
"Paul Rubin" <pr****@equilter.com> wrote in message
news:f9**************************@posting.google.c om...
Hi all. I'm wondering if there's a way to have checkboxes become
selected without clicking the mouse. Perhaps if you rollover the
checkboxes, they could toggle checked and unchecked? Or perhaps you
could click-and-hold and then drag across a series of checkboxes to
select them?

Please let me know,
Sincerely,
Paul Rubin
pr****@equilter.com

Like the following? Watch for word-wrap.

<html>
<head>
<title>checkme.htm</title>
<script language="javascript" type="text/javascript">
<!--
function mouser() {
var form = document.forms[0];
if (form.box1.checked) {
form.box1.checked = false;
} else {
form.box1.checked = true;
}
}
// -->
</script>
</head>
<body>
<form>
<input type="checkbox" name="box1" value="1" onmouseover="mouser()">
</form>
</body>
</html>

Jul 20 '05 #4
"Paul Rubin" <pr****@equilter.com> wrote in message
news:f9**************************@posting.google.c om...
Thanks for your kind reply. How about if there are a whole bunch of
checkboxes, with names, p.1, p.2, p.3, etc ???

I hope this can be incorporated!
Sincerely,
Paul Rubin
pr****@equilter.com


The following does what you want.
(I've used JW's elegant approach.)
Watch for word-wrap.

<html>
<head>
<title>checkers.htm</title>
</head>
<body>
<form>
<input type="checkbox" name="p.1" value="One"
onmouseover="this.checked=!this.checked">
<input type="checkbox" name="p.2" value="Two"
onmouseover="this.checked=!this.checked">
<input type="checkbox" name="p.3" value="Three"
onmouseover="this.checked=!this.checked">
<input type="checkbox" name="p.4" value="Four"
onmouseover="this.checked=!this.checked">
</form>
</body>
</html>


Jul 20 '05 #5
Works like a charm!
Thank you,
Sincerely,
Paul Rubin
pr****@equilter.com

"McKirahan" <Ne**@McKirahan.com> wrote in message news:<czZHb.69570$VB2.136182@attbi_s51>...
"Paul Rubin" <pr****@equilter.com> wrote in message
news:f9**************************@posting.google.c om...
Thanks for your kind reply. How about if there are a whole bunch of
checkboxes, with names, p.1, p.2, p.3, etc ???

I hope this can be incorporated!
Sincerely,
Paul Rubin
pr****@equilter.com


The following does what you want.
(I've used JW's elegant approach.)
Watch for word-wrap.

<html>
<head>
<title>checkers.htm</title>
</head>
<body>
<form>
<input type="checkbox" name="p.1" value="One"
onmouseover="this.checked=!this.checked">
<input type="checkbox" name="p.2" value="Two"
onmouseover="this.checked=!this.checked">
<input type="checkbox" name="p.3" value="Three"
onmouseover="this.checked=!this.checked">
<input type="checkbox" name="p.4" value="Four"
onmouseover="this.checked=!this.checked">
</form>
</body>
</html>

Jul 20 '05 #6

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

Similar topics

2
by: john | last post by:
hi I am generating a set of dynamic checkboxes via php. I have to check that the uer should atleast check one checkbox. When there are more then 1 checkbox my javascript works but if there is...
4
by: Michael Champagne | last post by:
We have an application to where you can select/deselect all checkboxes in a checkbox array by clicking a 'master' checkbox at the top of the screen. This seems to work fine unless there is only...
4
by: Marc | last post by:
Is there a way to produce 3 radio buttons, which when one is selected, enables 11 check boxes which are otherwise disabled (greyed out)? EXAMPLE: Option 1 --Radio buttons Option 2 Option 3 ...
2
by: john | last post by:
I posted this question to comp.lang.javascript but didn't get a response, so I'll try here. I am using ASP.NET and I have a datagrid. One of the columns in my grid is all checkboxes. When the...
0
by: Machi | last post by:
> let say i created nested repeaters in HTML page of a particular Web Form Parent repeater dubbed >> "parentRepeater", child Repeater dubbed "childRepeater" . Withi "parentRepeater" and...
5
by: Jimmy | last post by:
Hi I am trying to check whether checkboxes are checked in my user control. I have problems getting the right reference to the checkboxes: <%@ Page language="c#" Codebehind="WebForm2.aspx.cs"...
24
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to...
13
by: Oleg Konovalov | last post by:
Hi, I am working on a web application which among other things uses DHTML, Java and Javascript. It populates web page based on the contents of the database (resultset), and next to each row...
1
Frinavale
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...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
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
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
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, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...

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.