Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Check and Uncheck All Checkboxes

838 views
Skip to first unread message

ItsMillerTime4u

unread,
Oct 27, 2005, 12:01:59 PM10/27/05
to
I'm trying to find a way to check and uncheck all checkboxes through
vbscript in a HTA. I found this website:
http://www.shiningstar.net/articles/articles/javascript/checkboxes.asp?ID=AW
which shows hot to do it using Javascript, but I'm trying to do in
vbscript, and I'm not really an expert at converting javascript code to
vbscript.
Thanks for the help.

P.S. Here is the code from
http://www.shiningstar.net/articles/articles/javascript/checkboxes.asp?ID=AW


<SCRIPT LANGUAGE="JavaScript">
<!--
// by Nannette Thacker
// http://www.shiningstar.net
// This script checks and unchecks boxes on a form
// Checks and unchecks unlimited number in the group...
// Pass the Checkbox group name...
// call buttons as so:
// <input type=button name="CheckAll" value="Check All"
//onClick="checkAll(document.myform.list)">
// <input type=button name="UnCheckAll" value="Uncheck All"
//onClick="uncheckAll(document.myform.list)">
// -->

<!-- Begin
function checkAll(field)
{
for (i = 0; i < field.length; i++)
field[i].checked = true ;
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
field[i].checked = false ;
}
// End -->
</script>

Here is the HTML:

<form name="myform" action="checkboxes.asp" method="post">
<b>Your Favorite Scripts & Languages</b><br>
<input type="checkbox" name="list" value="1">Java<br>
<input type="checkbox" name="list" value="2">Javascript<br>
<input type="checkbox" name="list" value="3">Active Server Pages<br>
<input type="checkbox" name="list" value="4">HTML<br>
<input type="checkbox" name="list" value="5">SQL<br>

<input type="button" name="CheckAll" value="Check All"
onClick="checkAll(document.myform.list)">
<input type="button" name="UnCheckAll" value="Uncheck All"
onClick="uncheckAll(document.myform.list)">
<br>
</form>

McKirahan

unread,
Oct 27, 2005, 11:06:54 PM10/27/05
to
"ItsMillerTime4u" <itsmill...@yahoo.com> wrote in message
news:1130428919....@g49g2000cwa.googlegroups.com...

> I'm trying to find a way to check and uncheck all checkboxes through
> vbscript in a HTA. I found this website:
>
http://www.shiningstar.net/articles/articles/javascript/checkboxes.asp?ID=AW
> which shows hot to do it using Javascript, but I'm trying to do in
> vbscript, and I'm not really an expert at converting javascript code to
> vbscript.
> Thanks for the help.

[snip]

Only tested under IE5.5.

<html>
<head>
<title>checkboxes.htm</title>
<script type="text/vbscript">
Sub checkAll(field)
For i = 0 To field.length - 1
field(i).checked = true
Next
End Sub
Sub uncheckAll(field)
For i = 0 To field.length - 1
field(i).checked = false
Next
End Sub
</script>
</head>
<body>


<form name="myform" action="checkboxes.asp" method="post">
<b>Your Favorite Scripts & Languages</b>
<br><input type="checkbox" name="list" value="1">Java
<br><input type="checkbox" name="list" value="2">Javascript

<br><input type="checkbox" name="list" value="3">ASP


<br><input type="checkbox" name="list" value="4">HTML
<br><input type="checkbox" name="list" value="5">SQL
<br>
<input type="button" name="CheckAll" value="Check All"
onClick="checkAll(document.myform.list)">
<input type="button" name="UnCheckAll" value="Uncheck All"
onClick="uncheckAll(document.myform.list)">

</form>
</body>
</html>


0 new messages