469,927 Members | 1,731 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

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

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
4 1268
gits
5,390 Expert Mod 4TB
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
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
16,027 Expert Mod 8TB
Have a look at this tutorial.

Please use code tags when posting code:

[CODE=javascript]
JavaScript code here.
[/code]
Oct 15 '07 #4
acoder
16,027 Expert Mod 8TB
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.

Similar topics

3 posts views Thread by Stefan Richter | last post: by
2 posts views Thread by shankwheat | last post: by
1 post views Thread by giloosh | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.