pacchy
asked on
Adding an option to the combo box when it is empty (differs in IE5 and IE5.5)
IN HTML
I am creating an object opt1 as below
opt1 = document.createElement("OP TION")
and I am assigning text and value to the object opt1.
opt1.text = "name";
opt1.value = "1234";
Then I am adding this as an option in a combobox.
combo1.options.add(opt1);
If the combo1 is empty, in Internet Explorer 5 this addtion will result in one option added in the combobox.
If the combo1 is empty, the same piece of code adds two options of the same text and values in Internet Explorer 5.5.
Can any body help in resolving this.
I am creating an object opt1 as below
opt1 = document.createElement("OP
and I am assigning text and value to the object opt1.
opt1.text = "name";
opt1.value = "1234";
Then I am adding this as an option in a combobox.
combo1.options.add(opt1);
If the combo1 is empty, in Internet Explorer 5 this addtion will result in one option added in the combobox.
If the combo1 is empty, the same piece of code adds two options of the same text and values in Internet Explorer 5.5.
Can any body help in resolving this.
CJ to get that to work I think you have to pre-define size either with
a size attribute on the select or like this
obj = document.forms["formname"] ["combonam e"];
obj.size=1;
obj[obj.length] = new Option("text", "value");
Otherwise length is either -1 or undefined. I'm not sure which, but
it does not work until I sized.
pacchy,
your code work for me in IE5.5 are you sure that you only
populating once.
To confirm, I set it up with size="2" and when I added the option it added
just one.
when I don't size it, is start out a tiny size and when I add the option
it adds it just once.
Cd&
a size attribute on the select or like this
obj = document.forms["formname"]
obj.size=1;
obj[obj.length] = new Option("text", "value");
Otherwise length is either -1 or undefined. I'm not sure which, but
it does not work until I sized.
pacchy,
your code work for me in IE5.5 are you sure that you only
populating once.
To confirm, I set it up with size="2" and when I added the option it added
just one.
when I don't size it, is start out a tiny size and when I add the option
it adds it just once.
Cd&
ASKER
I got it resolved the problem was that i should not add the text and value before adding the opt1...
thanks
thanks
This question has been abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.
Cd&
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.
Cd&
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Per recommendation (https://www.experts-exchange.com/jsp/qShow.jsp?qid=20259555) comment force/accepted.
pacchy,
Some of these questions have been open for some time. Please resolve them appropriately as soon as possible.
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20089066
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20118334
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20226674
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20228288
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20195966
Thanks,
Netminder
Community Support Moderator
Experts Exchange
pacchy,
Some of these questions have been open for some time. Please resolve them appropriately as soon as possible.
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20089066
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20118334
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20226674
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20228288
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20195966
Thanks,
Netminder
Community Support Moderator
Experts Exchange
obj = document.forms["formname"]
obj[obj.length] = new Option("text", "value");
CJ