1

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.

http://pastebin.com/aqvX222V

asked Mar 11, 2013 at 13:11

2 Answers 2

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
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, though this partialy worked, since im getting an "Undefined" value at the bottom of Dropdown 2.
Welcome.. I missied out a small updation.. and the updated answer works perfectly... Happy to be Helpful..
1

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];
 }
}
answered Mar 11, 2013 at 13:23

2 Comments

Thank you, but this did not work for me, but the solution above worked.
Opps, I've make some careless mistake, and seems the above solution is shorter.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.