Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with mozilla firefox browser while creating dynamic dropdown list

 
sruthi reddy
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
In my application, i am crreating a dynamic drop down list using javascript and its working fine when i am using IE browser. If i am trying same with firefox, its not wotking. Can anyone suggest me how to solve this issue. Here is the code which i am using.

function addOption(selectbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}

Problem is with the line " selectbox.options.add(optn); ". Can anyone suggest me alternate option or how to make this work.

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I recall correctly, W3C standards, which of course IE ignores almost completely, dictate a second parameter to the add() method that specifies the position of the option in the list.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic