hi, my aim is to select multiple email, if i do select select all (check all), with this code i'm able to do correctly with IE but not on FireFox..How can I achive this for firefox? Here is javascript code... <script language="javascript" type="text/javascript"> <!-- function calc_delid() { var str=""; for (i = 1; i < document.forms("form1").length; i++) { if(document.forms("form1").item(i).name == "ch") { if(document.forms("form1").item(i).checked == true) { str+=' `Id`='; str+=document.forms("form1").item(i).value; str+=' or '; } } } document.forms("form1").item("delid").value=str.substring(1,str.length - 3); //alert(str.substring(1,str.length - 3)); } function delMe() { if (document.forms("form1").item("delid").value == "" ) { alert("Select Mail for Delete."); } else { if (confirm("Delete the Mail ? ")==true){ //alert(document.frmMailList.delid.value); document.form1.doAction.value="delThis" document.form1.action="default.asp" ; form1.submit(); } else{ document.forms("form1").item("delid").value=""; alert("Mail has been not Deleted !"); } } } function ch_onclick(var1) { var str=""; if (var1.checked == false) { document.forms("form1").item("all").checked=false; } else { var flag=true; for (i = 1; i < document.forms("form1").length; i++) { if(document.forms("form1").item(i).name == "ch") { if(document.forms("form1").item(i).checked == false) { flag = false; break; } } } document.forms("form1").item("all").checked=flag; } calc_delid(); } function all_onclick() { var flag; flag=document.forms("form1").item("all").checked; for (i = 1; i < document.forms("form1").length; i++) { if( document.forms("form1").item(i).name == "ch") { document.forms("form1").item(i).checked=flag; } } calc_delid(); } Code (markup): Here is some HTML code <form id="form1" name="form1"> <table align="center" bgcolor="#ffffff" border="0" cellpadding="1" cellspacing="1" width="95%"> <tbody> <tr> <td class="header" align="center" height="19" width="6%"><input onclick="all_onclick()" class="checkbox" value="1" name="all" id="all" type="checkbox"> <input id="delid" name="delid" type="hidden"> </td> <td class="header" height="19" width="63%"> Email Id </td> <td class="header" align="center" height="19" width="31%"><div align="center">Status </div></td> </tr> <tr style="background-color: rgb(244, 244, 244);" onmouseover="this.style.backgroundColor='#FEFAEB';" onmouseout="this.style.backgroundColor='#f4f4f4';" bgcolor="#f4f4f4"> <td align="center"><input id="5" class="checkbox" value="5" name="ch" onclick="ch_onclick(this)" type="checkbox"> </td> <td> someone@microsoft.com</td> <td class="matter" align="center"><div align="center">Yes </div></td> </tr> <tr style="background-color: rgb(244, 244, 244);" onmouseover="this.style.backgroundColor='#FEFAEB';" onmouseout="this.style.backgroundColor='#f4f4f4';" bgcolor="#f4f4f4"> <td align="center"><input id="6" class="checkbox" value="6" name="ch" onclick="ch_onclick(this)" type="checkbox"> </td> <td> somefrom@yahoo.com</td> <td class="matter" align="center"><div align="center">No </div></td> </tr> <tr> <td colspan="3" align="left"><input name="action" class="buttoncolor" id="action" value="Trash" type="submit"> <input name="action" class="buttoncolor" id="action" value="Active" type="submit"> <input name="action" class="buttoncolor" id="action" value="InActive" type="submit" width="20"> </td> </tr> </tbody> </table> </form> Code (markup):
The reason that works in IE and not Firefox is because you're using JScript syntax, not javascript. Change your syntax to be like document.forms["form1"].elements[i].name Code (markup):
I suggest always go for standard DOM syntax; and test your Javascript code in Mozilla browsers, I prefere Firefox, because any thing that works in mozilla browser it will work in IE 99% of the time or 100% in my case. I have never faced any javascript problem, when I followed standard syntax and tested in mozilla browsers.