• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;
}
}
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic