atsalis
asked on
Select/Unselect script does not work on firefox
Dear Experts hi,
I am using the following script to select/unselect all select boxes on a form named reg. The select boxes are named c1 to c10
The form declaration is as follows:
<form id="reg" name="reg" method="post" action="something.php">
<a href="javascript:checkAll( )">Select/ Unselect All</a>
<input name="c1" type="checkbox" id="something" value="1" />
.
.
.
<input name="c10" type="checkbox" id="something" value="10" />
</form>
I have the firebug installed on my firefox and it gives me the error in question...
The funny thing is that I have set up another html page to use this script and it works great on firefox but not on the template I am using. I dont know if there is someother javascrpt code that I allready have set up on this template that conflicts and causes the error
reg is not defined var chkObj = eval('reg.' + chkArr[count]);
...either way any help will be appreciated. And of course if you need more info please ask. Thanks a lot...
I am using the following script to select/unselect all select boxes on a form named reg. The select boxes are named c1 to c10
The form declaration is as follows:
<form id="reg" name="reg" method="post" action="something.php">
<a href="javascript:checkAll(
<input name="c1" type="checkbox" id="something" value="1" />
.
.
.
<input name="c10" type="checkbox" id="something" value="10" />
</form>
I have the firebug installed on my firefox and it gives me the error in question...
The funny thing is that I have set up another html page to use this script and it works great on firefox but not on the template I am using. I dont know if there is someother javascrpt code that I allready have set up on this template that conflicts and causes the error
reg is not defined var chkObj = eval('reg.' + chkArr[count]);
...either way any help will be appreciated. And of course if you need more info please ask. Thanks a lot...
function checkAll(){
var chkArr = ["c1","c2","c3","c4","c5","c6","c7","c8","c9","c10"];
var frmObj = document.getElementById('reg');
for(var count=0;count < chkArr.length;count++){
var chkObj = eval('reg.' + chkArr[count]);
if(typeof(chkObj) != "undefined"){
chkObj.checked = !chkObj.checked;
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot it worked...however can I ask you why it used to work they way I did it before on another page?...? Do you think there may be some other Javascript tht I have that conflicts with that one?
>>Do you think there may be some other Javascript tht I have that conflicts with that one?
No.
>>why it used to work they way I did it before on another page
Can't tell for sure. One possibility is that "reg" on another page may have been a shortcut for
document.forms.reg
Ex:
var reg = document.forms.reg
then when evaled as you did, then it should work.
No.
>>why it used to work they way I did it before on another page
Can't tell for sure. One possibility is that "reg" on another page may have been a shortcut for
document.forms.reg
Ex:
var reg = document.forms.reg
then when evaled as you did, then it should work.
ASKER
Ok I guess that sets it...thanks a lot mate....
Open in new window