473,624 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

checkbox script works in IE, but not in Firefox

3 New Member
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_ch eckbox"); //******
// This function is used to fill the differents forms with the
// office selection
sel=checkbox.va lue;
if (checkbox.check ed==true) //if the checkbox is checked then we add selection
{
add_selection(' form1','selecti on',sel);
}
if (checkbox.check ed==false) //else we delete selection
{
del_selection(' form1','selecti on',sel)
}
}

function add_selection(f orm_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_custom er=document.for ms(form_name).e lements(input_n ame).value
if (document.forms (form_name)!=nu ll)
{
alert("document .forms name != null"); //******
if (document.forms (form_name).ele ments(input_nam e).value=="") //if the list is empty, no need to add "-"
{
selected_custom er = elet;
alert("adding selection1:"+do cument.form1.se lection.value); //******
}
else
{
selected_custom er = "-" + elet;
alert("adding selection2:"+do cument.form1.se lection.value); //******
}
document.forms( form_name).elem ents(input_name ).value += selected_custom er;
}
}

function del_selection(f orm_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)!=nu ll)
{
alert("document .forms name != null"); //******
search = elet;
selected_custom er = document.forms( form_name).elem ents(input_name ).value;
selected_custom er=selected_cus tomer.replace(s earch,'');
selected_custom er = selected_custom er.replace('--','-');
if (selected_custo mer.substr(sele cted_customer.l ength-1,selected_cust omer.length)=="-")
{
selected_custom er=selected_cus tomer.substr(0, selected_custom er.length-1);
alert("removing selection1:"+do cument.form1.se lection.value); //******
}
if (selected_custo mer.substr(0,1) =="-")
{
selected_custom er=selected_cus tomer.substr(1, selected_custom er.length-1);
alert("removing selection2:"+do cument.form1.se lection.value); //******
}
document.forms( form_name).elem ents(input_name ).value = selected_custom er;
}
}

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

function Input_Check(ena m)
{
if ((enam == "") && (document.form1 .selection.valu e==""))
{
alert("Enter model number and select office(s) !");
alert("selectio n value:"+documen t.form1.selecti on.value);
return false;
}
if ((enam != "") && (document.form1 .selection.valu e==""))
{
alert("You must select office(s) !");
alert("selectio n value:"+documen t.form1.selecti on.value);
return false;
}
if ((enam == "") && (document.form1 .selection.valu e!=""))
{
alert("Enter model number!");
alert("selectio n value:"+documen t.form1.selecti on.value);
return false;
}
if ((enam != "") && (document.form1 .selection.valu e!=""))
{
ret=afCheck(doc ument.form1.ena m);
return true;
}

}
// ]]> -->
</SCRIPT>
[/HTML]
Jul 12 '07 #1
3 3680
acoder
16,027 Recognized Expert Moderator MVP
What errors do you see? Check the error console.
Jul 12 '07 #2
uremog
3 New Member
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
16,027 Recognized Expert Moderator MVP
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

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

Similar topics

0
2123
by: claudel | last post by:
Hi I have a newb PHP/Javascript question regarding checkbox processing I'm not sure which area it falls into so I crossposted to comp.lang.php and comp.lang.javascript. I'm trying to construct a checkbox array in a survey form where one of the choices is "No Preference" which is checked by default. If the victim chooses other than "No Preference", I'd like to uncheck
4
8410
by: Matt | last post by:
In ASP page, there is a "SELECT ALL" button, when user click it, it will select all checkboxes. I am not sure should I use client-side code to do that? the following is my approach but it didnt work. <script language="JavaScript"> function selectAllCheckBox() { //alert(document.addzone.c1.value); document.addzone.c1.value = "on"; } </script>
5
5630
by: Randell D. | last post by:
Folks, I have a few <INPUT TYPE=TEXT> tags that are readonly if a specific field has no value... these work fine. However, I also have checkboxes which I would like to have as readonly, but the same code doesn't work - Can someone suggest a solution? This is sample code extracted from my original code: // Before other input tags determine if they are read only or not,
5
6437
by: Ed Jay | last post by:
This has to be easy, but I'm at a loss. In an externally linked js, I create a checkbox using innerHTML. How do I test the value or test to see if it's checked while still within the js? -- Ed Jay (remove M to respond by email)
1
4014
by: spolsky | last post by:
try the the following code with Opera 9.01 (Windows). when clicked slightly faster than normal clicking, the toggler checkbox and other checkboxes displays differently although event method works fine to update the checkboxes. there is not any problem with IE 6 or FireFox 1.5. also, i used the double click event method to see if its the source but that does not help even. Opera 9.01 seems to be slow at updating checkboxes visually. am i...
10
5194
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked. I set the AutoPostBack property of the CheckBox in the Header to True & am invoking a sub named 'CheckAllRows' on the CheckedChanged event of this CheckBox. The CheckBox in the Header exists within the HeaderTemplate of a TemplateColumn in the...
2
18269
by: AmitKu | last post by:
<script> function CheckChange() { var mycheck = document.getElementById('test'); mycheck.check = true; } </script> <body> <form id="form1" runat="server">
5
2258
by: empiresolutions | last post by:
Hello Fellow Developers, I am using the awesome drag and drop script found at http://script.aculo.us/. I have also added a modification that interacts to a db for reordering upon release of a dragable item. Within each dragable is a input checkbox. This checkbox holds a DB id value that is sent on submit. This process works fine in IE, but in FF the checkbox values dont get sent via GET, or POST. How do i get FF to react as i think it...
2
5619
by: Martin | last post by:
At the top of a page I'm displaying a check box thus: <input type='checkbox' name='ckbx1' onClick='saveStatus("ckbx1");'>ABC I then execute the following to set the check box to whatever it was the last time it was changed: <script type='text/javascript'> document.getElementById('ckbx1').checked = getCookie('ckbx1'); </script>
0
8231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8168
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8672
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7153
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4075
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2603
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.