Connecting Tech Pros Worldwide Help | Site Map

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

Newbie
 
Join Date: May 2007
Posts: 29
#1: May 11 '07
Hi all,
combo box script code was working in IE perfectly with all modes but OnChange event was not working in FireFox(editable 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
Newbie
 
Join Date: May 2007
Posts: 29
#2: May 15 '07

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


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 displayComboValues(comboName,comboValue){
if(document.formmain(comboName).type=='select-one'){
var optn = document.createElement("OPTION");
optn.text = comboValue;
optn.value = comboValue;
document.formmain(comboName).options.add(optn);
document.formmain(comboName).options[document.formmain(comboName).length-1].selected=true;
}else{
document.formmain(comboName).value=comboValue;
}
}

pls help me to overcome this situvation
iam_clint's Avatar
Forum Leader
 
Join Date: Jul 2006
Location: Oklahoma
Posts: 1,076
#3: May 15 '07

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


I need to see the form also
Newbie
 
Join Date: May 2007
Posts: 29
#4: May 16 '07

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


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
Newbie
 
Join Date: May 2007
Posts: 29
#5: May 16 '07

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


Quote:

Originally Posted by iam_clint

I need to see the form also



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


<td width="65%" align="center" valign="center" >
<select name="medDirection0" style="font-family:Verdana; font-size: 8pt; color: #000000;border: 0px solid #666666 ; BORDER-WIDTH: 1px; BORDER-STYLE: inset; width:500px" class="subvalue" onKeyDown="fnKeyDownHandler(this, event);" onKeyUp="fnKeyUpHandler_A(this, event); return false;" onKeyPress = "return fnKeyPressHandler_A(this, event);" onChange="fnChangeHandler_A(this, event);" onChange="fnChangeHandler_A(this, event);" value="<jsp:getProperty name="_adminBean" property="medDirection"/>">
<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>
displayComboValues("medDirection0",'<%=_adminBean. getMedDirection()%>');
</Script>

</td>


hi above three satements r using for displaying the combo box values displayComboValues("medDirection0",'<%=_adminBean. getMedDirection()%>');
</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. displayComboValues()method code yesterday i posted already .


pls help me to overcome this situvation

Regards
SivaKumar
Newbie
 
Join Date: May 2007
Posts: 29
#6: May 16 '07

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


Quote:

Originally Posted by buss123

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


<td width="65%" align="center" valign="center" >
<select name="medDirection0" style="font-family:Verdana; font-size: 8pt; color: #000000;border: 0px solid #666666 ; BORDER-WIDTH: 1px; BORDER-STYLE: inset; width:500px" class="subvalue" onKeyDown="fnKeyDownHandler(this, event);" onKeyUp="fnKeyUpHandler_A(this, event); return false;" onKeyPress = "return fnKeyPressHandler_A(this, event);" onChange="fnChangeHandler_A(this, event);" onChange="fnChangeHandler_A(this, event);" value="<jsp:getProperty name="_adminBean" property="medDirection"/>">
<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>
displayComboValues("medDirection0",'<%=_adminBean. getMedDirection()%>');
</Script>

</td>


hi above three satements r using for displaying the combo box values displayComboValues("medDirection0",'<%=_adminBean. getMedDirection()%>');
</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. displayComboValues()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?
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#7: May 16 '07

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


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)
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#8: May 16 '07

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


Just noticed the duplicate thread. I've merged the threads. Please do not double-post.
Newbie
 
Join Date: May 2007
Posts: 29
#9: May 30 '07

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


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. }
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#10: May 30 '07

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


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.   }
Newbie
 
Join Date: May 2007
Posts: 29
#11: Jun 1 '07

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


Hi all, i am using javascript code getting combo box. But in IE it is displaying with selected values but in FireFox insted of selected values it is displaying empty combo box. for displaying combo box values i am using following code pls tell me where is the mistake in the code


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. }

thanking u
dmjpro's Avatar
Lives Here
 
Join Date: Jan 2007
Location: India (West-Bengal)
Posts: 2,451
#12: Jun 1 '07

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


Try to use ....Option.

Expand|Select|Wrap|Line Numbers
  1. var combo_box = document.formname.obj_name;
  2. combo_box.options.length = 0; //Empty.
  3. combo_box.options[0] = new Option(value_0,text_0);
  4. //-------
  5. combo_box.options[n-1] = new Option(value_n_1,text_n_1);
  6.  
now see the effect.

kind regards.
dmjpro.
Newbie
 
Join Date: May 2007
Posts: 29
#13: Jun 11 '07

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


Hi all i am using javascript function for displaying the combobox values but it is working in IE Fine, but in FireFox it is not displaying any values i am getting only blank combo box only.please help me too overcome the situvation my code follows as

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. }
thanking u
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#14: Jun 11 '07

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


All three threads merged.

See my reply. The add method must have two arguments for Firefox and standards-compliant browsers.
Newbie
 
Join Date: May 2007
Posts: 29
#15: Jun 12 '07

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


Quote:

Originally Posted by acoder

All three threads merged.

See my reply. The add method must have two arguments for Firefox and
standards-compliant browsers.



thanks for reply . , even though i use 2 parameter it is not working in firefox pls help me

Thanking u
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#16: Jun 12 '07

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


Post your code. Remember you have to use null for the second argument as I posted earlier.
Newbie
 
Join Date: May 2007
Posts: 29
#17: Jun 13 '07

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


Quote:

Originally Posted by acoder

Post your code. Remember you have to use null for the second argument as I posted earlier.


here i am posting my code this also working in IE but not in FF 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. try{
  7. document.formmain(comboName).options.add(optn,null);
  8. }
  9. catch(ex){
  10. document.formmain(comboName).options.add(optn);
  11. }
  12. document.formmain(comboName).options[document.formmain(comboName).length-1].selected=true;
  13. }else{
  14. document.formmain(comboName).value=comboValue;
  15. }
  16. }
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#18: Jun 13 '07

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


Instead of
Expand|Select|Wrap|Line Numbers
  1. if(document.formmain(comboName).type=='select-one'){
try:
Expand|Select|Wrap|Line Numbers
  1. if(document.formmain[comboName].name=='select-one'){
Surely, you mean the name, not the type.

Perhaps you could post your form HTML as well as how you are calling this function.
Newbie
 
Join Date: May 2007
Posts: 29
#19: Jun 14 '07

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


Quote:

Originally Posted by acoder

Instead of

Expand|Select|Wrap|Line Numbers
  1. if(document.formmain(comboName).type=='select-one'){
try:
Expand|Select|Wrap|Line Numbers
  1. if(document.formmain[comboName].name=='select-one'){
Surely, you mean the name, not the type.

Perhaps you could post your form HTML as well as how you are calling this function.



hi ,
even i change it if(document.formmain(comboName).name=='select-one'){ no use same thing happening . here i am sending code how i am declaering and calling combobox

[HTML]<td width="40%" align="center" valign="center" >
<select name="medDirection<%=i%>" style="font-family:Verdana; font-size: 8pt; color: #000000;border: 0px solid #666666 ; BORDER-WIDTH: 1px; BORDER-STYLE: inset; width:500px" class="subvalue" onKeyDown="fnKeyDownHandler(this, event);" onKeyUp="fnKeyUpHandler_A(this, event); return false;" onKeyPress = "return fnKeyPressHandler_A(this, event);" onChange="fnChangeHandler_A(this, event);"
value="<jsp:getProperty name="_adminBean" property="medDirection"/>">
<option value=""></option>
<option value="AC">AC</option>
<option value="BID">BID</option>
<option value="GT">GT</option>
<option value="HS">HS</option>
<option value="OD">OD</option>
</select>
</td>[/HTML]


for displaying these combo box values calling the method like this
<Script>
displayComboValues("medDirection0",'<%=_adminBean. getMedDirection()%>');
</Script>

pls tell me where is the problem

Thanking u
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#20: Jun 14 '07

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


What's "select-one"? The type of a combo box is going to be "select".

Do you get any errors? If so, on what line?
Newbie
 
Join Date: May 2007
Posts: 29
#21: Jun 15 '07

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


Quote:

Originally Posted by acoder

What's "select-one"? The type of a combo box is going to be "select".

Do you get any errors? If so, on what line?



select-one is the combobox name . we didnt get any errors . combobox working fine but the values are not displaying in the FireFox .


Thanking u
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#22: Jun 15 '07

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


The name of the combo box that you're passing is "MedDirection0"
Newbie
 
Join Date: Nov 2005
Posts: 7
#23: Jul 3 '07

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


Ok, i know this comes a little late on the topic, but i had to comment on this.

build a select box (size=1 line)
give it some dummy options
now, add the following

onchange="alert(this.type)"

any guess what it will return? i will give you a hint, it's not "select"

it will return "select-one" and if it's a multiple select it will return... yes, you guessed it "select-multiple"

so checking on the o.type=="select-one" is perfectly valid;

just thought i would weigh in on that.


Quote:

Originally Posted by acoder

Instead of

Expand|Select|Wrap|Line Numbers
  1. if(document.formmain(comboName).type=='select-one'){
try:
Expand|Select|Wrap|Line Numbers
  1. if(document.formmain[comboName].name=='select-one'){
Surely, you mean the name, not the type.

Perhaps you could post your form HTML as well as how you are calling this function.

Newbie
 
Join Date: Nov 2005
Posts: 7
#24: Jul 3 '07

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


bus, did you ever solve this?

i wonder if the problem isn't the fact that you are addressing the element with the wrong indexing operator... actually i am surprised it's working in any broswer

rather then
Expand|Select|Wrap|Line Numbers
  1. document.formname(formelement).type==
try
Expand|Select|Wrap|Line Numbers
  1. document.formname[formElement].type==
note the [ rather then (


Quote:

Originally Posted by buss123

select-one is the combobox name . we didnt get any errors . combobox working fine but the values are not displaying in the FireFox .


Thanking u

gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,128
#25: Jul 3 '07

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


Quote:

Originally Posted by voxecho

Ok, i know this comes a little late on the topic, but i had to comment on this.

build a select box (size=1 line)
give it some dummy options
now, add the following

onchange="alert(this.type)"

any guess what it will return? i will give you a hint, it's not "select"

it will return "select-one" and if it's a multiple select it will return... yes, you guessed it "select-multiple"

so checking on the o.type=="select-one" is perfectly valid;

just thought i would weigh in on that.

;) interesting hint i tested it and of course you're right ... i didn't know about that (and never needed it yet but good to know now) ... thank you for this ...

kind regards ...
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#26: Jul 4 '07

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


Quote:

Originally Posted by voxecho

Ok, i know this comes a little late on the topic, but i had to comment on this.

build a select box (size=1 line)
give it some dummy options
now, add the following

onchange="alert(this.type)"

any guess what it will return? i will give you a hint, it's not "select"

it will return "select-one" and if it's a multiple select it will return... yes, you guessed it "select-multiple"

so checking on the o.type=="select-one" is perfectly valid;

just thought i would weigh in on that.

Interesting - I didn't know that. Thanks for pointing that out.

Incidentally, I found this - silly me for not checking.
Newbie
 
Join Date: May 2007
Posts: 29
#27: Oct 22 '07

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


Hi all,
the following line of code is working fine in IE but the same line of code is not working in Firefox . can any one help me is there any other way to write the same line of code for firefox.

if(document.formmain(comboName).type=='select-one')

my main doubt is 'select-one' will work in firefox or not? if not pls tell me is there any alternative for that.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#28: Oct 22 '07

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


This reminds me of your earlier thread. Is it the same problem?
Newbie
 
Join Date: May 2007
Posts: 29
#29: Oct 23 '07

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


Quote:

Originally Posted by acoder

This reminds me of your earlier thread. Is it the same problem?



Yes after a long time again i shifteed to that problem again , what is the compatiable word to "select-one"
Familiar Sight
 
Join Date: Feb 2007
Posts: 207
#30: Oct 23 '07

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


Quote:

Originally Posted by buss123

Yes after a long time again i shifteed to that problem again , what is the compatiable word to "select-one"

You still don't seem to understand, the problem has nothing to do with the type identifier.

The syntax
Expand|Select|Wrap|Line Numbers
  1. document.formmain(comboName)
is incorrect as it constitutes a function call not a reference. The Firefox error console must be indicating this.

Expand|Select|Wrap|Line Numbers
  1. if(document.formmain[comboName].type=='select-one')
Ferris's Avatar
Member
 
Join Date: Oct 2007
Location: Shanghai
Posts: 102
#31: Oct 23 '07

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


hi

type= ='select-one' can work in firefox and IE,because this property is defined in DOM Level1,but you should get the 'select' by using DOM. for example:

[HTML]
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<select id="listmul" name="listmul" multiple></select>
<br />
<script language="javascript">
<!--
document.write ( document.getElementById("listmul").type);
-->
</script>

<br />
<select id="listsgl" name="listsgl"></select>
<br />
<script language="javascript">
<!--
document.write ( document.getElementById("listsgl").type);
-->
</script>
</body>
</html>
[/HTML]


the output is

select-multiple
select-one

hope it helps.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#32: Oct 24 '07

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


Quote:

Originally Posted by buss123

Yes after a long time again i shifteed to that problem again , what is the compatiable word to "select-one"

Merged the threads then.
Newbie
 
Join Date: May 2007
Posts: 29
#33: Oct 24 '07

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


Quote:

Originally Posted by Logician

You still don't seem to understand, the problem has nothing to do with the type identifier.

The syntax

Expand|Select|Wrap|Line Numbers
  1. document.formmain(comboName)
is incorrect as it constitutes a function call not a reference. The Firefox error console must be indicating this.

Expand|Select|Wrap|Line Numbers
  1. if(document.formmain[comboName].type=='select-one')


Thank U very much for ur reply now it working fine in both IE and FF
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#34: Oct 24 '07

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


Quote:

Originally Posted by buss123

Thank U very much for ur reply now it working fine in both IE and FF

Well, after almost 5 months, aren't you glad?

It shouldn't have worked in any browser in the first place.
Reply