By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,027 Members | 1,111 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,027 IT Pros & Developers. It's quick & easy.

not showing correct options in selectbox while creating it dynamically in opera

P: 5
i have two select boxes.based on the selected value in one select box it show the maximum options in the other select box in next page.i used javascript onclick function.for first time it shows correct options in the second select box if i go back and change the value in the 1st select box it shows me the previous value in the 2nd select box,the value not get changed.it is happening only in opera9 all the other browsers its working fine.it seems that only for first time the function clears all the options in the selectbox for second time it is not clearing the options it just reload it.

Expand|Select|Wrap|Line Numbers
  1. while (changedVal.options.length)
  2.     {
  3.         changedVal.remove(0);
  4.         changedVal.options[0] = null;
  5.     }
  6.     for (var i=1; i<=maxiVal; i++) 
  7.     {
  8.         if(i==DefVal)
  9.         {
  10.             optionName = new Option(i+defaultText, i, false, true);
  11.         }
  12.         else
  13.         {
  14.         optionName = new Option(i, i, false, false);
  15.         }
  16.         changedVal.options[changedVal.length] = optionName;
  17.     }
Oct 12 '07 #1
Share this Question
Share on Google+
4 Replies


gits
Expert Mod 5K+
P: 5,320
hi ...

welcome to TSDN ...

i've moved your thread from the js articles-section to the forum for you ... please don't post questions to the articles sections ...

kind regards
Oct 12 '07 #2

P: 5
opera9.23
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 java script 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
Expand|Select|Wrap|Line Numbers
  1. function CalBasedMaxVal(selVal,changedVal,maxiVal,DefVal)
  2. {
  3. var CalBasedSelValue=selVal.selectedIndex+1;
  4. var defaultText = '-['+lang_text_ary['default']+']';
  5. var optionName;
  6. while (changedVal.options.length)
  7. {
  8. changedVal.remove(0);
  9. changedVal.options[0] = null;
  10. }
  11. for (var i=1; i<=maxiVal; i++) 
  12. {
  13. if(i==DefVal)
  14. {
  15. optionName = new Option(i+defaultText, i, false, true);
  16. }
  17. else
  18. {
  19. optionName = new Option(i, i, false, false);
  20. }
  21. changedVal.options[changedVal.length] = optionName;
  22. }
  23. }
Oct 12 '07 #3

acoder
Expert Mod 15k+
P: 16,027
Have a look at this tutorial.

Please use code tags when posting code:

[CODE=javascript]
JavaScript code here.
[/code]
Oct 15 '07 #4

acoder
Expert Mod 15k+
P: 16,027
Merged duplicate threads. Please do not double post.
Oct 15 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.