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. - 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;
-
}
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
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 - 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;
-
}
-
}
Have a look at this tutorial.
Please use code tags when posting code:
[CODE=javascript]
JavaScript code here.
[/code]
Merged duplicate threads. Please do not double post.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
| |