Is there any way I can combine this into one button, so when its clicked it checks all the boxes, and when its clicked again, it unchecks all the boxes.
I've seen it done before but not sure how to go about it.
function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
if(!document.forms[FormName])
return;
var objCheckBoxes = document.forms[FormName].elements[FieldName];
if(!objCheckBoxes)
return;
var countCheckBoxes = objCheckBoxes.length;
if(!countCheckBoxes)
objCheckBoxes.checked = CheckValue;
else
// set the check value for all check boxes
for(var i = 0; i < countCheckBoxes; i++)
objCheckBoxes[i].checked = CheckValue;
}
Last edited by s.dot on Sun May 07, 2006 3:20 pm, edited 1 time in total.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
heh i was actually ahead of you on that one
I just tried it. It does set the checkboxes, but doesn't do anything when clicked to unset them.
This would be a handy code snippet when we're finished. you can take all the credit
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
function doCheck(state,FormName,FieldName)
{
var F = document.forms[FormName].elements[FieldName];
var len = F.length;
for(i=0; i<len; i++)
if(F.type == "checkbox")
F.checked = state;
}
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
you forgot to attach indexes to F
also added
- a permanent storage for state so that same button acts as select and deselect btn
- a view of parameters passed
- a view of properties when an object is not a checkbox
I have a feeling it's close though. and I didn't FORGET, i just don't know HOW =]
DOH!!
Edit: I added var infront of state = !state; and it seems to work for checking them. gotta get rid of the alerts and try unchecking them
Edit #2: Not unchecking
Edit #3: The alert always says 'commentList : cid[] : 2 : true' on check and uncheck
Many thanks for helping me.
any ideas on getting the uncheck all working?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
I got n00b sailbots post working by adding the state = false; to the top of it! I didn't see it before because it wasn't inside the function.
Many thanks!
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.