This topic is locked

Populate a second dropdown object

5/11/2011 3:11:27 PM
PHPRunner General questions
F
Fhernd author

Hello!
I want to populate a dropdown object throughout JavaScript as follows:

switch( ctrlDepartamento.getValue() )

{

case "Cundinamarca":
alert( ctrlDepartamento.getValue() )



ctrlCiudad.options[0] = new Option("Bogotá","Bogotá" )

ctrlCiudad.options[1] = new Option("Chía","Chía" )

ctrlCiudad.options[2] = new Option("Alban","Alban" )
// etc

break;
// etc
};
ctrlDepartamento.on('change', okeh);


ctrlDepartamento and ctrlCiudad (synonymous of ctrlState and ctrlCity in English, respectively) are dropdown objects.
But it does not work. What is happening? What is wrong?
Thanks in advance for your appreciated help.
So long!

Sergey Kornilov admin 5/11/2011

You won't be able to do so using Javascript API - its designed for different purpose.
In this situation you can use jQuery. Here are a few examples that can help:

http://www.electrictoolbox.com/jquery-add-option-select-jquery/

F
Fhernd author 5/12/2011



You won't be able to do so using Javascript API - its designed for different purpose.
In this situation you can use jQuery. Here are a few examples that can help:

http://www.electrictoolbox.com/jquery-add-option-select-jquery/


How do I can accomplish this task? Where I include the jQuery.js file? Thanks in advance!

Sergey Kornilov admin 5/12/2011

jQuery is included already. You just need to change your code that adds new options to dropdown box.