470,613 Members | 2,448 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,613 developers. It's quick & easy.

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 8095
"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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Shock | last post: by
17 posts views Thread by Mike Gratee | last post: by
3 posts views Thread by Jamie Jackson | last post: by
2 posts views Thread by RobG | last post: by
2 posts views Thread by Sedef | last post: by
6 posts views Thread by Nx | last post: by
7 posts views Thread by extremerep | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.