Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkboxes

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Is it possible to set a large number(1000 or more) checkboxes, without this taking forever??

(im using document.all.tags("INPUT")=true)
 
What are you trying to do? Set them all to checked on the fly, or just write a loop of code that generates hundreds of already checked checkboxes?

Matt.
 
Try this program - if it's not what you want you should be able to work with it

Matt.

<html>
<head>
<title>Untitled</title>
<script language=&quot;JavaScript&quot;>
<!--
function tickBoxes(){
for (i=0;i<100;i++){
document.forms[0].elements.checked=true
}
}
//-->
</script>
</head>

<body>
<form>
<script language=&quot;JavaScript&quot;>
<!--
for (i=0;i<100;i++) {
document.write (&quot;<input type='checkbox' name='box + i + '>&quot;)
}
//-->
</script>
<input type=&quot;button&quot; value=&quot;check all boxes&quot; onClick=&quot;tickBoxes()&quot;>
</form>

</body>
</html>
 
Try this program - this'll do a hundred for you. If it's not quite what you want you should be able to work with this..

Matt.

<html>
<head>
<title>Untitled</title>
<script language=&quot;JavaScript&quot;>
<!--
function tickBoxes(){
for (i=0;i<100;i++){
document.forms[0].elements.checked=true
}
}
//-->
</script>
</head>

<body>
<form>
<script language=&quot;JavaScript&quot;>
<!--
for (i=0;i<100;i++) {
document.write (&quot;<input type='checkbox' name='box + i + '>&quot;)
}
//-->
</script>
<input type=&quot;button&quot; value=&quot;check all boxes&quot; onClick=&quot;tickBoxes()&quot;>
</form>

</body>
</html>
 
The problem is that it takes forever when you have i.e. 1000 boxes......
 
if you want them to start off as checked, just change the line below to include the bold part:

document.write (&quot;<input checked type='checkbox' name='box + i + '>&quot;)


jared@aauser.com
 
I got groups of checkboxes with the same name but no value set. The nuber of checkboxes that appear on the form depends on the information in the database.

How can i write a JavaScript that will find out when a particular checkbox has been checked ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top