473,791 Members | 3,154 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Combo box code is Working in IE perfectly but it is not working in FireFox

29 New Member
Hi all,
combo box script code was working in IE perfectly with all modes but OnChange event was not working in FireFox(editabl e mode, if we select valuese that combo box values r not dislaying if enter the data the it is inserting properly) javascript code follows

pls help me to solve this problem


Expand|Select|Wrap|Line Numbers
  1.   function fnKeyDownHandler(getdropdown, e)
  2.   {
  3.     fnSanityCheck(getdropdown);
  4.  
  5.     var vEventKeyCode = FindKeyCode(e);
  6.     if(vEventKeyCode == 37)
  7.     {
  8.     fnLeftToRight(getdropdown);
  9.     }
  10.     if(vEventKeyCode == 39)
  11.     {
  12.     fnRightToLeft(getdropdown);
  13.     }
  14.     if(vEventKeyCode == 46)
  15.     {
  16.     fnDelete(getdropdown);
  17.     }
  18.  
  19.     if(vEventKeyCode == 8 || vEventKeyCode==127)
  20.     {
  21.     if(e.which) 
  22.     {
  23.  
  24.     }
  25.     else 
  26.     {
  27.  
  28.       e.keyCode = '';
  29.       if(window.event.keyCode)
  30.       {
  31.       window.event.keyCode = '';
  32.       }
  33.     }
  34.     return true;
  35.     }
  36.  
  37.   }
  38.  
  39.   function fnLeftToRight(getdropdown)
  40.   {
  41.     getdropdown.style.direction = "ltr";
  42.   }
  43.  
  44.   function fnRightToLeft(getdropdown)
  45.   {
  46.     getdropdown.style.direction = "rtl";
  47.   }
  48.  
  49.   function fnDelete(getdropdown)
  50.   {
  51.     if(getdropdown.options.length != 0)
  52.  
  53.     {
  54.     if (getdropdown.options.selectedIndex == vEditableOptionIndex_A)
  55.  
  56.     {
  57.       getdropdown.options[getdropdown.options.selectedIndex].text = '';
  58.  
  59.     }
  60.     }
  61.   }
  62.   function FindKeyCode(e)
  63.   {
  64.     if(e.which)
  65.     {
  66.     keycode=e.which; 
  67.     }
  68.     else
  69.     {
  70.     keycode=e.keyCode; 
  71.     }
  72.     return keycode;
  73.   }
  74.  
  75.   function FindKeyChar(e)
  76.   {
  77.     keycode = FindKeyCode(e);
  78.     if((keycode==8)||(keycode==127))
  79.     {
  80.     character="backspace"
  81.     }
  82.     else if((keycode==46))
  83.     {
  84.     character="delete"
  85.     }
  86.     else
  87.     {
  88.     character=String.fromCharCode(keycode);
  89.     }
  90.  
  91.     return character;
  92.   }
  93.  
  94.   function fnSanityCheck(getdropdown)
  95.   {
  96.     if(vEditableOptionIndex_A>(getdropdown.options.length-1))
  97.     {
  98.     alert("PROGRAMMING ERROR: The value of variable vEditableOptionIndex_... cannot be greater than (length of dropdown - 1)");
  99.     return false;
  100.     }
  101.   }
  102.   var vEditableOptionIndex_A = 0;
  103.  
  104.   var vEditableOptionText_A = "--?--";
  105.  
  106.  
  107.  
  108.   var vPreviousSelectIndex_A = 0;
  109.  
  110.   var vSelectIndex_A = 0;
  111.  
  112.   var vSelectChange_A = 'MANUAL_CLICK';
  113.  
  114.  
  115.   function fnChangeHandler_A(getdropdown)
  116.   {
  117.     fnSanityCheck(getdropdown);
  118.  
  119.     vPreviousSelectIndex_A = vSelectIndex_A;
  120.  
  121.     vSelectIndex_A = getdropdown.options.selectedIndex;
  122.  
  123.  
  124.     if ((vPreviousSelectIndex_A == (vEditableOptionIndex_A)) && (vSelectIndex_A != (vEditableOptionIndex_A))&&(vSelectChange_A != 'MANUAL_CLICK'))
  125.  
  126.     {
  127.       getdropdown[(vEditableOptionIndex_A)].selected=true;
  128.       vPreviousSelectIndex_A = vSelectIndex_A;
  129.       vSelectIndex_A = getdropdown.options.selectedIndex;
  130.       vSelectChange_A = 'MANUAL_CLICK';
  131.  
  132.     }
  133.   }
  134.  
  135.   function fnKeyPressHandler_A(getdropdown, e)
  136.   {
  137.     fnSanityCheck(getdropdown);
  138.  
  139.     keycode = FindKeyCode(e);
  140.     keychar = FindKeyChar(e);
  141.  
  142.  
  143.  
  144.     if ((keycode>47 && keycode<59)||(keycode>62 && keycode<127) ||(keycode==32) ||(keycode==46))
  145.     {
  146.       var vAllowableCharacter = "yes";
  147.     }
  148.     else
  149.     {
  150.       var vAllowableCharacter = "no";
  151.     }
  152.     if(getdropdown.options.length != 0)
  153.       if (getdropdown.options.selectedIndex == (vEditableOptionIndex_A))
  154.             {
  155.         var vEditString = getdropdown[vEditableOptionIndex_A].text;
  156.         if((vAllowableCharacter == "yes")||(keychar=="backspace"))
  157.         {
  158.           if (vEditString == vEditableOptionText_A)
  159.             vEditString = "";
  160.         }
  161.         if (keychar=="backspace")
  162.  
  163.         {
  164.           vEditString = vEditString.substring(0,vEditString.length-1);
  165.  
  166.           vSelectChange_A = 'MANUAL_CLICK';
  167.                  }
  168.         if (vAllowableCharacter == "yes")
  169.  
  170.         {
  171.           vEditString+=String.fromCharCode(keycode);          
  172.           var i=0;
  173.           var vEnteredChar = String.fromCharCode(keycode);
  174.           var vUpperCaseEnteredChar = vEnteredChar;
  175.           var vLowerCaseEnteredChar = vEnteredChar;
  176.           if(((keycode)>=97)&&((keycode)<=122))
  177.  
  178.             vUpperCaseEnteredChar = String.fromCharCode(keycode - 32);
  179.  
  180.           if(((keycode)>=65)&&((keycode)<=90))
  181.  
  182.             vLowerCaseEnteredChar = String.fromCharCode(keycode + 32);
  183.  
  184.           if(e.which) 
  185.           {
  186.  
  187.             for (i=0;i<=(getdropdown.options.length-1);i++)
  188.             {
  189.               if(i!=vEditableOptionIndex_A)
  190.               {
  191.                 var vReadOnlyString = getdropdown[i].text;
  192.                 var vFirstChar = vReadOnlyString.substring(0,1);
  193.                 if((vFirstChar == vUpperCaseEnteredChar)||(vFirstChar == vLowerCaseEnteredChar))
  194.                 {
  195.                   vSelectChange_A = 'AUTO_SYSTEM';
  196.  
  197.                   break;
  198.                 }
  199.                 else
  200.                 {
  201.                   vSelectChange_A = 'MANUAL_CLICK';
  202.  
  203.                 }
  204.               }
  205.             }
  206.           }
  207.         }
  208.  
  209.  
  210.         getdropdown.options[vEditableOptionIndex_A].text = vEditString;
  211.  
  212.         getdropdown.options[vEditableOptionIndex_A].value = vEditString; //Use this line only if want to change the internal value too; else this line is not required.
  213.  
  214.         return false;
  215.       }
  216.     return true;
  217.   }
  218.  
  219.   function fnKeyUpHandler_A(getdropdown, e)
  220.   {
  221.     fnSanityCheck(getdropdown);
  222.  
  223.     if(e.which) 
  224.     {
  225.       if(vSelectChange_A == 'AUTO_SYSTEM')
  226.       {
  227.  
  228.         getdropdown[(vEditableOptionIndex_A)].selected=true;
  229.       }
  230.  
  231.       var vEventKeyCode = FindKeyCode(e);
  232.  
  233.       if((vEventKeyCode == 37)||(vEventKeyCode == 39))
  234.       {
  235.         getdropdown[vEditableOptionIndex_A].selected=true;
  236.       }
  237.     }
  238.   }
Please post code using code tags - moderator

pls help me i am not able to do this
May 11 '07 #1
33 5564
buss123
29 New Member
hi all,
this is sivakumar, i am using javascript function for displaying the values but it is working well in IE fine but that function was not working in Firefox Please help me to solve the above situvation . code follows as below


function displayComboVal ues(comboName,c omboValue){
if(document.for mmain(comboName ).type=='select-one'){
var optn = document.create Element("OPTION ");
optn.text = comboValue;
optn.value = comboValue;
document.formma in(comboName).o ptions.add(optn );
document.formma in(comboName).o ptions[document.formma in(comboName).l ength-1].selected=true;
}else{
document.formma in(comboName).v alue=comboValue ;
}
}

pls help me to overcome this situvation
May 15 '07 #2
iam_clint
1,208 Recognized Expert Top Contributor
I need to see the form also
May 15 '07 #3
buss123
29 New Member
Hi all,
i am using javascript function for displaying the values in the edit mode. it was working fine in the IE but not working in the Firefox pls help me to display the values in the both IE and Firefox .

my code follws


Expand|Select|Wrap|Line Numbers
  1. function displayComboValues(comboName,comboValue){
  2. if(document.formmain(comboName).type=='select-one'){
  3. var optn = document.createElement("OPTION");
  4. optn.text = comboValue;
  5. optn.value = comboValue;
  6. document.formmain(comboName).options.add(optn);
  7. document.formmain(comboName).options[document.formmain(comboName).length-1].selected=true;
  8.     }else{
  9. document.formmain(comboName).value=comboValue;
  10. }
  11. }
pls help me to overcome this situvation
May 16 '07 #4
buss123
29 New Member
I need to see the form also


<script language=javasc ript src='../jsp/DropDowns.js'></script>


<td width="65%" align="center" valign="center" >
<select name="medDirect ion0" style="font-family:Verdana; font-size: 8pt; color: #000000;border: 0px solid #666666 ; BORDER-WIDTH: 1px; BORDER-STYLE: inset; width:500px" class="subvalue " onKeyDown="fnKe yDownHandler(th is, event);" onKeyUp="fnKeyU pHandler_A(this , event); return false;" onKeyPress = "return fnKeyPressHandl er_A(this, event);" onChange="fnCha ngeHandler_A(th is, event);" onChange="fnCha ngeHandler_A(th is, event);" value="<jsp:get Property name="_adminBea n" property="medDi rection"/>">
<option value=""></option>
<option value="AC">AC</option>
<option value="BID">BID </option>
<option value="GT">GT</option>
<option value="HS">HS</option>

</select>



<Script>
displayComboVal ues("medDirecti on0",'<%=_admin Bean.getMedDire ction()%>');
</Script>

</td>


hi above three satements r using for displaying the combo box values displayComboVal ues("medDirecti on0",'<%=_admin Bean.getMedDire ction()%>');
</Script>

this method was working in the IE but it is not working in the Firefox . in Firefox the selected combobox values r displaying empty. displayComboVal ues()method code yesterday i posted already .


pls help me to overcome this situvation

Regards
SivaKumar
May 16 '07 #5
buss123
29 New Member
<script language=javasc ript src='../jsp/DropDowns.js'></script>


<td width="65%" align="center" valign="center" >
<select name="medDirect ion0" style="font-family:Verdana; font-size: 8pt; color: #000000;border: 0px solid #666666 ; BORDER-WIDTH: 1px; BORDER-STYLE: inset; width:500px" class="subvalue " onKeyDown="fnKe yDownHandler(th is, event);" onKeyUp="fnKeyU pHandler_A(this , event); return false;" onKeyPress = "return fnKeyPressHandl er_A(this, event);" onChange="fnCha ngeHandler_A(th is, event);" onChange="fnCha ngeHandler_A(th is, event);" value="<jsp:get Property name="_adminBea n" property="medDi rection"/>">
<option value=""></option>
<option value="AC">AC</option>
<option value="BID">BID </option>
<option value="GT">GT</option>
<option value="HS">HS</option>

</select>



<Script>
displayComboVal ues("medDirecti on0",'<%=_admin Bean.getMedDire ction()%>');
</Script>

</td>


hi above three satements r using for displaying the combo box values displayComboVal ues("medDirecti on0",'<%=_admin Bean.getMedDire ction()%>');
</Script>

this method was working in the IE but it is not working in the Firefox . in Firefox the selected combobox values r displaying empty. displayComboVal ues()method code yesterday i posted already .


pls help me to overcome this situvation

Regards
SivaKumar

Sir form meens total form section in the jsp page?
May 16 '07 #6
acoder
16,027 Recognized Expert Moderator MVP
Where do you get the error? What errors do you see?

I'm assuming you see the error on the "add" method.

See this thread.

Also, see the source on this link (see comments - add with one argument is IE-only, not standard-compliant)
May 16 '07 #7
acoder
16,027 Recognized Expert Moderator MVP
Just noticed the duplicate thread. I've merged the threads. Please do not double-post.
May 16 '07 #8
buss123
29 New Member
Hi all ,
i am new to javascript the following function is working IE well but it is not working in FireFox pls help me to solve this problem it is very urgent for me. Pls help me

my code follows

Expand|Select|Wrap|Line Numbers
  1. function displayComboValues(comboName,comboValue){
  2. if(document.formmain(comboName).type=='select-one'){
  3. var optn = document.createElement("OPTION");
  4. optn.text = comboValue;
  5. optn.value = comboValue;
  6. document.formmain(comboName).options.add(optn);
  7. document.formmain(comboName).options[document.formmain(comboName).length-1].selected=true;
  8.     }else{
  9. document.formmain(comboName).value=comboValue;
  10. }
  11. }
May 30 '07 #9
acoder
16,027 Recognized Expert Moderator MVP
The add method should have two arguments.

The standards compliant way would be:
Expand|Select|Wrap|Line Numbers
  1. options.add(optn, null);
Unfortunately, this doesn't work in IE, so you would have to use the following code:
Expand|Select|Wrap|Line Numbers
  1. try {
  2.   document...options.add(optn, null); // standards compliant
  3. } catch(ex) {
  4.     ...options.add(optn); // IE
  5.   }
May 30 '07 #10

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

Similar topics

6
1996
by: christian9997 | last post by:
Hi I would be very helpful if someone could help me with this code. It works fine in IE but when I display it in Netscape or Firefox and I move the mouse from one menu to the other the gap between the two menus gets bigger. What is the cause of this? Thanks CODE:
2
5473
by: Sean | last post by:
Greetings all, I am attempting to make a form that will filter through several tables that (I believe) have refretial integrity. I am pulling data from several tables into the form and i would like to eventually be able to filter down through the tables untill i can reach one unique record. I am creating a datbase to keep track of registered accounts for a stae program. Each account is registered into the program through a two...
0
2078
by: cognoscento | last post by:
I'm currently putting together a database for my work (not an expert by any stretch, so muddling through as best as I can... you know the story...) and I could use some advice and hand-holding I've got a subform with a series of cascading combo boxes (thanks to the Access tutorials on fontstuff.com) that let the user assign categories to items, in this case photos. This is being done to help constrain user selections and keep the...
3
1925
by: neousr | last post by:
var row = document.createElement('TR'); row.setAttribute('class',tipoclase); ..... var cell = document.createElement('TD'); var theButton = document.createElement('input'); theButton.setAttribute('type','button'); theButton.setAttribute('value',description); theButton.setAttribute('class',ButtonClass); cell.appendChild(theButton); row.appendChild(cell);
2
2452
by: kiranmn75 | last post by:
I want to dynamically populate a combo box through javascript. Data is coming from a array. Sometimes data list may contain items in excess of 2000. Explorer takes more than 5 seconds to populate the combo (for a list of 2500). Can anybody optimize the code. I tried Duffs devise instead of 'for loop', but no improvement.
3
2477
by: mf193 | last post by:
Hi, I have a table of around 1000 rows; patient records. Each row is individually defined by a Patient ID number which is my primary key. I have made a simple form to display patient information for the secretaries working in the office. I would like them to be able to easily search through all the records using a combo box, that they can just type in the person's name. I have managed to make it work so far as when the last name is...
5
10109
by: atulvp | last post by:
Hi all, I have written a javascript code which changes the combo_2 options on runtime. It is working fine on IE but not working on Firefox. Please help me solve this problem. My code is as follows: function changeMe(str) { if(str.value == "se") { while(document.frm.combo2.length 0) {
6
2912
by: henry.onovwaka | last post by:
Can someone help on this problem. I have a combo box of, say three Items, selected from a table that serves as the lookup: E.g. 1 Earth, 2 Pine, 3 Earth Grave The combo box is on the subform. If the user selects any of the item, that item so selected should not appear in the list again; or The user should be warned about previous selection.
4
1829
Kitty001
by: Kitty001 | last post by:
Hi Guys I am new to MS Access and using MS Access2007. I have been fooling around with Access trying to solve this problem for weeks but i just cant seem to chack it and I need some help. I have a database based on the machines used for the maintenance of a golf course here in South Africa. I have tables containing the "Groups of Machines", "Machines" and the "Types of Fuel" they use with Prices per Lt. I have created a form thats been...
0
9669
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
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9997
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
9030
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...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
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();...
1
4110
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
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.