[Javascript] Re: turning on checkboxes
susan at plonka.com
susan at plonka.com
Mon Aug 13 15:32:12 CDT 2001
I'm having trouble getting your solution working. It says
document.memberForm.element is null or not an object. After printing
alert 1, it fails before alert 2. Any suggestions on how I might test
for nulls?
function selectAll(){
for ( var i =0; i < document.memberForm.length; i++){
alert("alert 1");
if ( document.memberForm.element[i] != null){
alert("alert 2");
if ( document.memberForm.element[i].type
== "checkbox"){
alert("alert 3");
document.memberForm.element
[i].checked = TRUE;
}
}
}
}
Thanks,
-Susan
------------------------Bob Filipiak -----------------------
function selectAll(){
for ( var i =0; i < document.forms[0].length; i++){
if ( document.forms[0].element[i].type == "checkbox"){
document.forms[0].element[i].checked = TRUE;
}
}
}
HTH
Bob Filipiak (Contractor)
MCP
-----Original Message-----
From: susan at plonka.com [mailto:susan at plonka.com]
Sent: Friday, August 10, 2001 10:48 AM
To: javascript at LaTech.edu
Subject: [Javascript] turning on checkboxes
I'm trying to figure out how to make a "Select All checkboxes" button
function.
The checkboxes are generated dynamically in a loop from reading a
database and their names correspond to the memberID. I don't know how
many, that's dynamic too.
I want to be able to get the checkbox names and turn them all on with
this button.
<script language="JavaScript">
function selectAll() {
document.members.cb1050.checked = true
}
<script>
<body><table> <!--- SQL stuff -->
<% do while not connMembers.eof %>
<tr><td>
<input type="checkbox" name="<%= connMembers(0) %>">
</td></tr>
<% connMembers.movenext
Loop %>
</table>
<table width="500"><tr><td width="100%" align="center">
<input type="button" value="Select All" onclick="selectAll
()">
</td></tr></table>
</body>
More information about the Javascript
mailing list