473,387 Members | 3,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 1390
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

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

Similar topics

3
by: Stefan Richter | last post by:
I would like to fill a Selectbox dynamically. I am taking all values from a db, and fill them into a selectbox. I guess the best way was to use some kind of a dynamical array, where you don't have...
2
by: shankwheat | last post by:
I have a form named 'choiceForm' and 2 select boxes named 'available' and 'move'. I give users the ability of copying options (not moving) from available to move with the code below. I would like...
1
by: swatipriyadarsani | last post by:
hi!!! i m creating website ...i m using ajax.When the page loads..there are 2 combo box one for state and other for city.on select of state city will get populated and on select of city my age will...
1
by: giloosh | last post by:
i would like to dynamically output such a selectbox below using php and mysql: <select> <option< 100 </option> <option100 to 150 </option> <option150 to 200 </option> <option200 to 250...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.