By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,978 Members | 1,373 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,978 IT Pros & Developers. It's quick & easy.

checkbox script works in IE, but not in Firefox

P: 3
I have a set of of check boxes. onClick, the checkboxes call check_radio and recup_checkbox. the referenced radios function as group selectors. check_radio just unchecks the radios if someone manually selects checkboxes.

i think the problem is in the add_selection and del_selection as suggested by the alerts, which are for debugging only. it gets as far as the alert(add/del selection) alerts in FF. all the alert tests pass in IE.

as the title says, this works fine in IE, but fails to pass InputCheck in Firefox, which checks if the search term (enam) is not empty and if the selection of checkboxes are not empty (the whole set of radios and checkboxes are under the "selection" form). selection.value always returns "" (empty string).

could anyone help me with how to change this to make it FF friendly?

Note:i took out some of the functions that i didn:t mention to make this shorter. this is all used with database info, so the number of checkboxes is variable. the ****s remind me whats a test script

[HTML]
<SCRIPT type="text/javascript">
<!-- <![CDATA[
function recup_checkbox(checkbox)
{
alert("recup_checkbox"); //******
// This function is used to fill the differents forms with the
// office selection
sel=checkbox.value;
if (checkbox.checked==true) //if the checkbox is checked then we add selection
{
add_selection('form1','selection',sel);
}
if (checkbox.checked==false) //else we delete selection
{
del_selection('form1','selection',sel)
}
}

function add_selection(form_name,input_name,elet)
{
alert("add selection"); //******
//this function add office code in the customer list
//form_name is a name of a form we want to change
//input_name is the name of the input value we want to change
//elet is the element to add
//the list is formatted to be used in a SQL request
selected_customer=document.forms(form_name).elemen ts(input_name).value
if (document.forms(form_name)!=null)
{
alert("document.forms name != null"); //******
if (document.forms(form_name).elements(input_name).va lue=="") //if the list is empty, no need to add "-"
{
selected_customer = elet;
alert("adding selection1:"+document.form1.selection.value); //******
}
else
{
selected_customer = "-" + elet;
alert("adding selection2:"+document.form1.selection.value); //******
}
document.forms(form_name).elements(input_name).val ue += selected_customer;
}
}

function del_selection(form_name,input_name,elet)
{
alert("del selection"); //******
//this function delete office code in the customer list
//form_name is a name of a form we want to change
//input_name is the name of the input value we want to change
//checkbox is a checkbox object
//the list is formatted to be used in a SQL request
if (document.forms(form_name)!=null)
{
alert("document.forms name != null"); //******
search = elet;
selected_customer = document.forms(form_name).elements(input_name).val ue;
selected_customer=selected_customer.replace(search ,'');
selected_customer = selected_customer.replace('--','-');
if (selected_customer.substr(selected_customer.length-1,selected_customer.length)=="-")
{
selected_customer=selected_customer.substr(0,selec ted_customer.length-1);
alert("removing selection1:"+document.form1.selection.value); //******
}
if (selected_customer.substr(0,1)=="-")
{
selected_customer=selected_customer.substr(1,selec ted_customer.length-1);
alert("removing selection2:"+document.form1.selection.value); //******
}
document.forms(form_name).elements(input_name).val ue = selected_customer;
}
}

function check_radio(objChkbx)
{
alert("removing all ji selection"); //******
for (i=0;i<document.form1.ji_selection.length;i++)
{
document.form1.ji_selection[i].checked=false
}
}

function Input_Check(enam)
{
if ((enam == "") && (document.form1.selection.value==""))
{
alert("Enter model number and select office(s) !");
alert("selection value:"+document.form1.selection.value);
return false;
}
if ((enam != "") && (document.form1.selection.value==""))
{
alert("You must select office(s) !");
alert("selection value:"+document.form1.selection.value);
return false;
}
if ((enam == "") && (document.form1.selection.value!=""))
{
alert("Enter model number!");
alert("selection value:"+document.form1.selection.value);
return false;
}
if ((enam != "") && (document.form1.selection.value!=""))
{
ret=afCheck(document.form1.enam);
return true;
}

}
// ]]> -->
</SCRIPT>
[/HTML]
Jul 12 '07 #1
Share this Question
Share on Google+
3 Replies


acoder
Expert Mod 15k+
P: 16,027
What errors do you see? Check the error console.
Jul 12 '07 #2

P: 3
thank you. i'm really not an html person, but i do use java, so with the error console i think i:ll be able to fix everything.

edit: and indeed i got it. whoever wrote the original was making bad calls to elements[] and form[], using elements() and form(), which apparently pass in IE, but firefox (and probably other browsers) are too strict for that.

thanks for the help.
Jul 13 '07 #3

acoder
Expert Mod 15k+
P: 16,027
thank you. i'm really not an html person, but i do use java, so with the error console i think i:ll be able to fix everything.

edit: and indeed i got it. whoever wrote the original was making bad calls to elements[] and form[], using elements() and form(), which apparently pass in IE, but firefox (and probably other browsers) are too strict for that.

thanks for the help.
Glad you got it. Yet another quirk from IE which is why you (not you, uremog, but just generally) should never test in IE first.
Jul 14 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.