PDA

View Full Version : [RESOLVED] Selecting all checkboxes


nin9919
04-04-2007, 03:46 PM
Newbie here... Is there any way to enter a command in the address bar that will "check" all the checkboxes on a page?
I checked the source of the page, and all checkboxes have the same name, only the value changes.

<input type="CHECKBOX" name='bulk' id='bulk' value='10008'>

One of my clients has this website for where we can search and print product information. Once the results are displayed, I can "check" the results I wan't and hit PRINT, bu there is no "Select All" button, and I can't get through to their webmaster.

I've seen some java tricks where you can enter "javascripit:etcetc" in the address bar to get the desired results. Is there anything similar that will let me select all the checkboxes on a page?

Any help will be appreciated.

Reminder: I am just a user, I have no control over the website, so I can't edit the source.

Jon Hanlon
04-04-2007, 09:19 PM
You could type
"javascript:var c = document.getElementById('bulk'); for(var j=0; j < c.length; j++) c[j].checked = true;"


To quickly check all the boxes, use the <tab> key to go to the next box, and hit the <spacebar> once to check it.

steverz
04-05-2007, 12:25 AM
This should help :)

<html>
<head>
<script type="text/javascript">
<!--
function checkAll()
{
var chkBox = document.mainFrm.checkboxfield
for(i=0; i<chkBox.length; i++)
{
chkBox[i].checked = true;
}
}
function unCheckAll() {
var chkBox = document.mainFrm.checkboxfield
for(i=0; i<chkBox.length; i++)
{
chkBox[i].checked = false;
}
}
//-->
</script>
</head>
<body>
<form name="mainFrm">
<input type="checkbox" name="checkboxfield" /> checkbox<br />
<input type="checkbox" name="checkboxfield" /> checkbox<br />
<input type="checkbox" name="checkboxfield" /> checkbox<br />
<input type="checkbox" name="checkboxfield" /> checkbox<br />
<input type="checkbox" name="checkboxfield" /> checkbox<br />
<input type="checkbox" name="checkboxfield" /> checkbox<br />
<input type="button" id="checkAllBoxes" value="Check All Boxes" onClick="checkAll()" /><br />
<input type="button" id="unCheckAllBoxes" value="Uncheck All Boxes" onClick="unCheckAll()" />
</form>
</body>
</html>

Jon Hanlon
04-05-2007, 01:44 AM
If there are more than just 'bulk' checkboxes, try:

javascript: var inps = document.getElementsByTagName("input");for (var j=0; j < inps.length; j++) if (inps[j].type == "checkbox") inps[j].checked = true;

nin9919
04-05-2007, 09:33 AM
Thanks Jon! That was exactly what I was looking for!


If there are more than just 'bulk' checkboxes, try:

javascript: var inps = document.getElementsByTagName("input");for (var j=0; j < inps.length; j++) if (inps[j].type == "checkbox") inps[j].checked = true;