I want to code something like below in Javascript.
I have a drop down which is loaded from array as below:
apple
orange
mango
grapes
Now if user selects mango from dropdown then I should reset my array to:
mango
grapes
apple
orange
Why don't you use the shift and push methods of Array inside a loop.
Eg.
var items = ["mango","grapes","apple"]
var selectedIndex = combo.selected.index
for( i = 0; i<selectedIndex ; i++){
items.push(items.shift())
}
combo.items = items
Im not a daily javascript programmer so this is just an idea.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.