aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes problem displaying the options in selectbox while creating it dynamically in opera9.2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "problem displaying the options in selectbox while creating it dynamically in opera9.2" Watch "problem displaying the options in selectbox while creating it dynamically in opera9.2" New topic
Author

problem displaying the options in selectbox while creating it dynamically in opera9.2

ram chml
Greenhorn

Joined: Oct 12, 2007
Posts: 4
i have two select boxes based on the selected value in one select box it should display the maximum options in the other select box.
i used javascript onClick for the first time it displays correct values again when i go back and change the value in the 1st selectbox the 2nd select box display previous values only.it works in all the browsers except opera.
my code is
function CalBasedMaxVal(selVal,changedVal,maxiVal,DefVal)
{
var CalBasedSelValue=selVal.selectedIndex+1;
var defaultText = '-['+lang_text_ary['default']+']';
var optionName;
while (changedVal.options.length)
{
changedVal.remove(0);
changedVal.options[0] = null;
}
for (var i=1; i<=maxiVal; i++)
{
if(i==DefVal)
{
optionName = new Option(i+defaultText, i, false, true);
}
else
{
optionName = new Option(i, i, false, false);
}
changedVal.options[changedVal.length] = optionName;
}
}
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Please be sure to use UBB code tags when posting code. It makes it a lot easier to read. Please read this for more information.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Adding options to a select by adding them to the options array can be iffy. Have you tried using the add() method of the select element? (Beware, IE has some issues with the order parameter of this method).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem displaying the options in selectbox while creating it dynamically in opera9.2