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

onClick onUnClick ???

The code shown below displays a table in a form with 3 check boxes.
When the left checkbox is selected, all other checkboxes are also
selected (hotmail style) (thanks for the groups help with this). The
onUnCick event doesn't work. Could anyone tell me how to correct it??

Thanks,

Ed

<html>
<head>
<title></title>
</head>
<body>

<form name=taskform action=test.php method=post>

<script language="JavaScript">
<!--
var row_1 = new Array("Monday0", "Monday1")
function check_boxes1(state)
{
for (y=0; y < row_1.length; y++)
{
for (i = 0; i < document.taskform.elements.length; i++)
{
if (document.taskform.elements[i].name == row_1[y])
document.taskform.elements[i].checked = state;
}
}
}
--> </script>

<table border=1 width=85%>
<tr>
<td class=small>Check increment</td>
<td class=small>toggle</td>
<td class=small>0:00</td><td class=small>1:00</td>
</tr>
<tr>
<td class=small>on the hour</td>
<td><input type=checkbox name=checkall_row1
onClick="check_boxes1(true)" onUnClick="check_boxes1(false)"></td>
<td><input type=checkbox name=Monday0></td>
<td><input type=checkbox name=Monday1></td>
</tr>
</table>
</form>
</body>
</html>
Jul 20 '05 #1
6 8333
"Edward" <eg****@hotmail.com> wrote in message
news:58**************************@posting.google.c om...
The code shown below displays a table in a form with 3 check boxes.
When the left checkbox is selected, all other checkboxes are also
selected (hotmail style) (thanks for the groups help with this). The
onUnCick event doesn't work. Could anyone tell me how to correct it??

Thanks,

Ed

<html>
<head>
<title></title>
</head>
<body>

<form name=taskform action=test.php method=post>

<script language="JavaScript">
<!--
var row_1 = new Array("Monday0", "Monday1")
function check_boxes1(state)
{
for (y=0; y < row_1.length; y++)
{
for (i = 0; i < document.taskform.elements.length; i++)
{
if (document.taskform.elements[i].name == row_1[y])
document.taskform.elements[i].checked = state;
}
}
}
--> </script>

<table border=1 width=85%>
<tr>
<td class=small>Check increment</td>
<td class=small>toggle</td>
<td class=small>0:00</td><td class=small>1:00</td>
</tr>
<tr>
<td class=small>on the hour</td>
<td><input type=checkbox name=checkall_row1
onClick="check_boxes1(true)" onUnClick="check_boxes1(false)"></td>
<td><input type=checkbox name=Monday0></td>
<td><input type=checkbox name=Monday1></td>
</tr>
</table>
</form>
</body>
</html>

There is no "onUnClick" event!

You'll have to test (in your JavaScript) whether or not the checkbox is
checked.

If it's no longer checked then treat it as an "UnClick".
Jul 20 '05 #2
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:qBgHb.493118$275.1390053@attbi_s53...
"Edward" <eg****@hotmail.com> wrote in message
news:58**************************@posting.google.c om...
The code shown below displays a table in a form with 3 check boxes.
When the left checkbox is selected, all other checkboxes are also
selected (hotmail style) (thanks for the groups help with this). The
onUnCick event doesn't work. Could anyone tell me how to correct it??

Thanks,

Ed

<html>
<head>
<title></title>
</head>
<body>

<form name=taskform action=test.php method=post>

<script language="JavaScript">
<!--
var row_1 = new Array("Monday0", "Monday1")
function check_boxes1(state)
{
for (y=0; y < row_1.length; y++)
{
for (i = 0; i < document.taskform.elements.length; i++)
{
if (document.taskform.elements[i].name == row_1[y])
document.taskform.elements[i].checked = state;
}
}
}
--> </script>

<table border=1 width=85%>
<tr>
<td class=small>Check increment</td>
<td class=small>toggle</td>
<td class=small>0:00</td><td class=small>1:00</td>
</tr>
<tr>
<td class=small>on the hour</td>
<td><input type=checkbox name=checkall_row1
onClick="check_boxes1(true)" onUnClick="check_boxes1(false)"></td>
<td><input type=checkbox name=Monday0></td>
<td><input type=checkbox name=Monday1></td>
</tr>
</table>
</form>
</body>
</html>

There is no "onUnClick" event!

You'll have to test (in your JavaScript) whether or not the checkbox is
checked.

If it's no longer checked then treat it as an "UnClick".

This variation of your code does what you want; watch for word-wrap:
<html>
<head>
<title>unclicks.htm</title>
<script language="JavaScript" type="text/lanaguage">
<!--
var row_1 = new Array("Monday0", "Monday1")
function check_boxes1() {
var form = document.taskform;
var state = false;
if (form.checkall_row1.checked) state = true;
for (y=0; y < row_1.length; y++) {
for (i = 0; i < form.elements.length; i++) {
if (form.elements[i].name == row_1[y])
form.elements[i].checked = state;
}
}
}
-->
</script>
</head>
<body>
<form name="taskform" action="test.php" method="post">
<table border="1" width="85%">
<tr>
<td class="small">Check increment</td>
<td class="small">toggle</td>
<td class="small">0:00</td>
<td class="small">1:00</td>
</tr>
<tr>
<td class=small>on the hour</td>
<td><input type="checkbox" name="checkall_row1"
onClick="check_boxes1()"></td>
<td><input type="checkbox" name="Monday0"></td>
<td><input type="checkbox" name="Monday1"></td>
</tr>
</table>
</form>
</body>
</html>
Note that I:
a) relocated the <script> within the <head> tags;
b) inserted type="text/lanaguage";
c) declare "var form = document.taskform;";
d) enclosed values (after "=") in quotes.

I have a habit of cleaning up other's code to my conventions...
Jul 20 '05 #3
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:fMgHb.54220$VB2.95096@attbi_s51...
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:qBgHb.493118$275.1390053@attbi_s53...
"Edward" <eg****@hotmail.com> wrote in message
news:58**************************@posting.google.c om...
The code shown below displays a table in a form with 3 check boxes.
When the left checkbox is selected, all other checkboxes are also
selected (hotmail style) (thanks for the groups help with this). The
onUnCick event doesn't work. Could anyone tell me how to correct it??

Thanks,

Ed

<html>
<head>
<title></title>
</head>
<body>

<form name=taskform action=test.php method=post>

<script language="JavaScript">
<!--
var row_1 = new Array("Monday0", "Monday1")
function check_boxes1(state)
{
for (y=0; y < row_1.length; y++)
{
for (i = 0; i < document.taskform.elements.length; i++)
{
if (document.taskform.elements[i].name == row_1[y])
document.taskform.elements[i].checked = state;
}
}
}
--> </script>

<table border=1 width=85%>
<tr>
<td class=small>Check increment</td>
<td class=small>toggle</td>
<td class=small>0:00</td><td class=small>1:00</td>
</tr>
<tr>
<td class=small>on the hour</td>
<td><input type=checkbox name=checkall_row1
onClick="check_boxes1(true)" onUnClick="check_boxes1(false)"></td>
<td><input type=checkbox name=Monday0></td>
<td><input type=checkbox name=Monday1></td>
</tr>
</table>
</form>
</body>
</html>

There is no "onUnClick" event!

You'll have to test (in your JavaScript) whether or not the checkbox is
checked.

If it's no longer checked then treat it as an "UnClick".

This variation of your code does what you want; watch for word-wrap:
<html>
<head>
<title>unclicks.htm</title>
<script language="JavaScript" type="text/lanaguage">
<!--
var row_1 = new Array("Monday0", "Monday1")
function check_boxes1() {
var form = document.taskform;
var state = false;
if (form.checkall_row1.checked) state = true;
for (y=0; y < row_1.length; y++) {
for (i = 0; i < form.elements.length; i++) {
if (form.elements[i].name == row_1[y])
form.elements[i].checked = state;
}
}
}
-->
</script>
</head>
<body>
<form name="taskform" action="test.php" method="post">
<table border="1" width="85%">
<tr>
<td class="small">Check increment</td>
<td class="small">toggle</td>
<td class="small">0:00</td>
<td class="small">1:00</td>
</tr>
<tr>
<td class=small>on the hour</td>
<td><input type="checkbox" name="checkall_row1"
onClick="check_boxes1()"></td>
<td><input type="checkbox" name="Monday0"></td>
<td><input type="checkbox" name="Monday1"></td>
</tr>
</table>
</form>
</body>
</html>
Note that I:
a) relocated the <script> within the <head> tags;
b) inserted type="text/lanaguage";
c) declare "var form = document.taskform;";
d) enclosed values (after "=") in quotes.

I have a habit of cleaning up other's code to my conventions...

Oops!

Change
type="text/lanaguage"
to
type="text/javascript"
Jul 20 '05 #4
In article <PTgHb.149595$8y1.436960@attbi_s52>, "McKirahan"
<Ne**@McKirahan.com> writes:
I have a habit of cleaning up other's code to my conventions...

Oops!

Change
type="text/lanaguage"
to
type="text/javascript"


Now if we can just get you to snip the ~116 lines that you quoted :)

--
Randy
Jul 20 '05 #5
McKirahan wrote:
[monologues]


How am I supposed to post my replies in a newsgroup?:
http://www.allmyfaqs.com/faq.pl?How_to_post
PointedEars
Jul 20 '05 #6
JRS: In article <3F**************@PointedEars.de>, seen in
news:comp.lang.javascript, Thomas 'PointedEars' Lahn
<Po*********@web.de> posted at Sat, 27 Dec 2003 18:03:50 :-
How am I supposed to post my replies in a newsgroup?:


If you do not know, you should read the FAQ of this newsgroup.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 20 '05 #7

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

Similar topics

8
by: Shock | last post by:
Hello everyone, I am having a problem with the program below. I have isolated the problem to the onclick event that is located throughout arrQuestions. The onclick event refers to a function...
17
by: Mike Gratee | last post by:
Is it possible to use JavaScript to cause the browser to click a link on a page and have the browser act exactly like the user had clicked on the link directly? In other words, I need to...
2
by: Kevin Lyons | last post by:
Hello, Can anyone assist me with what I am trying to do with the following code (six different scenarios to try to make the functionality work correctly)? I want to always (and ONLY) display...
3
by: Jamie Jackson | last post by:
I'm rewriting all links' onclick events, but I'm having a problem. The onclick event that I'm inserting works correctly in Opera, but not in FF or IE. I'm retroactively adding the statement...
2
by: RobG | last post by:
I am trying to dynamically add an onclick to an element, however I just can't get the syntax right. consider the following function: function doClick (evt,x) { // do things with evt and x } ...
2
by: Sedef | last post by:
Hi, i'm trying to create a custom Button user control which will be derived from System.Web.UI.WebControls.Button. the normal server side Button class creates some client side javascript code for...
6
by: Nx | last post by:
i've got it all working nicely in firefox, but whenever i test it in IE none of the onclick events are triggered. i'm using an xsl to transform an rss feed into a photogallery. when i try to...
7
by: extremerep | last post by:
My task is to change the value of a button and then make it functional with the onClick handler. Changing the value to "Play Again" works, but making the onClick work accordingly does not. 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
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: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...

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.