change the index position in dropdown
-
Hi, How to change the index position of dropdown list,for example if i select 2nd index value of dropdown ,after showing the result again it moves to 0th index , i want it to be remain in 2nd index value... need help.
-
Hi, How to change the index position of dropdown list,for example if i select 2nd index value of dropdown ,after showing the result again it moves to 0th index , i want it to be remain in 2nd index value... need help.
Before the page has been loaded, use the
selected
attribute.Not Selected Also Not Selected Selected
If you want it during run time; then use javascript.
document.getElementById('selectbox').selectedIndex = 2;
If at first you don't succeed, you're not Chuck Norris.
-
Before the page has been loaded, use the
selected
attribute.Not Selected Also Not Selected Selected
If you want it during run time; then use javascript.
document.getElementById('selectbox').selectedIndex = 2;
If at first you don't succeed, you're not Chuck Norris.
Thanks for your fast reply,I want the dropdown index should be changed during runtime,I dont want to assign the static value as 2, For the next if i select 3, then it will still remain in 2, I want the index to be changing as per user input.
-
Thanks for your fast reply,I want the dropdown index should be changed during runtime,I dont want to assign the static value as 2, For the next if i select 3, then it will still remain in 2, I want the index to be changing as per user input.
It was just an example. Obviously you would put it in a function.
function changeSelectedIndex(id, index)
{
document.getElementById(id).selectedIndex = index;
}changeSelectedIndex('selectbox', n);
Obviously, n can be any index (number) of your choice.
If at first you don't succeed, you're not Chuck Norris.
-
It was just an example. Obviously you would put it in a function.
function changeSelectedIndex(id, index)
{
document.getElementById(id).selectedIndex = index;
}changeSelectedIndex('selectbox', n);
Obviously, n can be any index (number) of your choice.
If at first you don't succeed, you're not Chuck Norris.
HI, Make a bit clear,changeSelectedIndex('selectbox', n); the 'n' is user choice or it changes dynamically at runtime.I want the index should be changed dynamically at runtime.I dont want to edit in code.
-
HI, Make a bit clear,changeSelectedIndex('selectbox', n); the 'n' is user choice or it changes dynamically at runtime.I want the index should be changed dynamically at runtime.I dont want to edit in code.