Associative Arrays and Populating Drop Downs and Text Boxes


John Clarke

In my code I want to create an associative array. For example :

On my view I want to have a drop down. How can I dynamically populate the drop down with the key values from the associative array (e.g. one, two, three) ?

As well as the drop down there will be 3 Text Input Boxes. The Input Boxes will be called one, two and three. So when I select one from the drop down the value of the Input Box called one will be set to Text Value 1. If I select two from the drop down the value of the input box called two will be set to Text Value 2.

How can I implement this ?


DecSoft

Hello John,

I think that can understand exactly what you wanted. The problem is the time... since you don't post an specific question... I will try to prepare an example for you as quickly as possible. They can take not too much time... or may the things become complex and more time is required... so let me to have some time in order to start with that sample and then I will post it here.



John Clarke

I thought I would post my solution to this issue :

I created a view with the following items :

On the show function for the view I added the following code :

and on the change function for the select box I added the following code :

My only concern is that is it sensible to use document.getElementById(SelectedItem).value in the code or is there a better method?


DecSoft

Hello John,

Your code it's quite curious, since, in principle, the DropDown controls expected a non associative Array: you provide an associative Array, so the control take the key's values. Maybe other do the things in other way, but, your code works as expected too.

About your concern, certainly you are not exactly set the value of the AB controls. Do that it's just replace one line of your code:

Doing that you can therefore access to the controls' "Value" variables like always.


Todo el mundo puede leer el foro de soporte de DecSoft para aprender del mismo, sin embargo, sólo los clientes de DecSoft pueden abrir nuevos hilos. Compre una o más licencias de productos de DecSoft y obtendrá este y otros beneficios.

Este sitio utiliza "cookies" útiles para almacenar sus preferencias.

Bien. Ocultar esta nota. Obtener más información.