Combo box code is Working in IE perfectly but it is not working in FireFox | Newbie | | Join Date: May 2007
Posts: 29
| |
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 Please post code using code tags - moderator
pls help me i am not able to do this
| | Newbie | | Join Date: May 2007
Posts: 29
| | | 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
|  | Forum Leader | | Join Date: Jul 2006 Location: Oklahoma
Posts: 1,076
| | | 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
| | | 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 - 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
| | Newbie | | Join Date: May 2007
Posts: 29
| | | 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
| | | 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?
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | 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)
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | 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
| | | 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 - 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;
-
}
-
}
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | 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:
Unfortunately, this doesn't work in IE, so you would have to use the following code: - try {
-
document...options.add(optn, null); // standards compliant
-
} catch(ex) {
-
...options.add(optn); // IE
-
}
| | Newbie | | Join Date: May 2007
Posts: 29
| | | 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 - 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;
-
}
-
}
thanking u
|  | Lives Here | | Join Date: Jan 2007 Location: India (West-Bengal)
Posts: 2,451
| | | re: Combo box code is Working in IE perfectly but it is not working in FireFox
Try to use ....Option. -
var combo_box = document.formname.obj_name;
-
combo_box.options.length = 0; //Empty.
-
combo_box.options[0] = new Option(value_0,text_0);
-
//-------
-
combo_box.options[n-1] = new Option(value_n_1,text_n_1);
-
now see the effect.
kind regards.
dmjpro.
| | Newbie | | Join Date: May 2007
Posts: 29
| | | 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 - 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;
-
}
-
}
thanking u
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | 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
| | | 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
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | 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
| | | 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 - function displayComboValues(comboName,comboValue){
-
if(document.formmain(comboName).type=='select-one'){
-
var optn = document.createElement("OPTION");
-
optn.text = comboValue;
-
optn.value = comboValue;
-
try{
-
document.formmain(comboName).options.add(optn,null);
-
}
-
catch(ex){
-
document.formmain(comboName).options.add(optn);
-
}
-
document.formmain(comboName).options[document.formmain(comboName).length-1].selected=true;
-
}else{
-
document.formmain(comboName).value=comboValue;
-
}
-
}
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: Combo box code is Working in IE perfectly but it is not working in FireFox
Instead of - if(document.formmain(comboName).type=='select-one'){
try: - 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
| | | re: Combo box code is Working in IE perfectly but it is not working in FireFox Quote:
Originally Posted by acoder Instead of - if(document.formmain(comboName).type=='select-one'){
try: - 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
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | 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
| | | 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
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | 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
| | | 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 - if(document.formmain(comboName).type=='select-one'){
try: - 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
| | | 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 - document.formname(formelement).type==
try - 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 |  | Moderator | | Join Date: May 2007 Location: Munich, Germany
Posts: 4,128
| | | 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 ...
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | 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
| | | 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.
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | 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
| | | 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
| | | 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 - document.formmain(comboName)
is incorrect as it constitutes a function call not a reference. The Firefox error console must be indicating this. - if(document.formmain[comboName].type=='select-one')
|  | Member | | Join Date: Oct 2007 Location: Shanghai
Posts: 102
| | | 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.
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | 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
| | | 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 - document.formmain(comboName)
is incorrect as it constitutes a function call not a reference. The Firefox error console must be indicating this. - if(document.formmain[comboName].type=='select-one')
Thank U very much for ur reply now it working fine in both IE and FF
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | 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.
|  | Similar JavaScript / Ajax / DHTML bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,374 network members.
|