SlickCatSeven
asked on
IE8 Javascript Function Not Working
This function doesn't work in IE8. I've tried altering many settings in IE, but nothing works, plus, I don't know if I can get my users to change settings. So, perhaps my javascript could be better. This function toggles all the checkboxes in a form on or off. Works in all browsers except IE8.
function toggle(source) {
checkboxes = document.getElementsByName ('prop[]') ;
for(var i in checkboxes)
checkboxes[c].checked = source.checked;
}
Mahalo for any help.
function toggle(source) {
checkboxes = document.getElementsByName
for(var i in checkboxes)
checkboxes[c].checked = source.checked;
}
Mahalo for any help.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hmm, doesn't seem to be working. Do I need to change the checkboxes themselves?
Here is the master toggle checkbox:
<input type="checkbox" onClick="toggle(this)" />
Checkboxes look like this:
<input type="checkbox" name="prop[]" value="1" />
<input type="checkbox" name="prop[]" value="2" />
<input type="checkbox" name="prop[]" value="3" />
Here is the master toggle checkbox:
<input type="checkbox" onClick="toggle(this)" />
Checkboxes look like this:
<input type="checkbox" name="prop[]" value="1" />
<input type="checkbox" name="prop[]" value="2" />
<input type="checkbox" name="prop[]" value="3" />
ASKER
Combined the two answers and it works.
function toggle(source) {
var checkboxes = document.getElementsByName ('prop[]') ;
var chk = source.checked;
for(var i = 0; i < checkboxes.length; i++)
checkboxes[i].checked = chk;
}
Thank you for the help.
function toggle(source) {
var checkboxes = document.getElementsByName
var chk = source.checked;
for(var i = 0; i < checkboxes.length; i++)
checkboxes[i].checked = chk;
}
Thank you for the help.
ASKER
function toggle(source) {
checkboxes = document.getElementsByName
for(var c in checkboxes)
checkboxes[c].checked = source.checked;
}