i have this script which allows the users to select from Dropdown 1, and it will fill Dropdown 2 with values. THOUGH the problem here is that once it fills, the original "item" called "-- Välj län först --" disappears, which i do not want it to do. I just want the new values to fill up under it. Could someone take a look at the code i supply below and see if there is an easy fix for this?
Thanks in advance.
2 Answers 2
See this : Sample
function showSubKommun(subCat,selectObj){
selectObj.length=kommun[subCat].length+1;
for(var n=1;n<=kommun[subCat].length;n++){
selectObj[n].text=kommun[subCat][n-1];
selectObj[n].value=kommun[subCat][n-1];
}
}
answered Mar 11, 2013 at 13:21
Anujith
9,3686 gold badges36 silver badges48 bronze badges
Sign up to request clarification or add additional context in comments.
Try this
function showSubKommun(subCat,selectObj){
selectObj.length=kommun[subCat].length+1;
selectObj[0].text=kommun[0][0];
selectObj[0].value=kommun[0][0];
for(var n=0;n<kommun[subCat].length;n++){
selectObj[n+1].text=kommun[subCat][n];
selectObj[n+1].value=kommun[subCat][n];
}
}
2 Comments
Andreas
Thank you, but this did not work for me, but the solution above worked.
Franky Lau
Opps, I've make some careless mistake, and seems the above solution is shorter.
lang-js