I have two select objects. When the first changes, i would like to write a procedure that updates the options in the second.
The data is stored in a multidimentionnal array generated by php. The output looks something like this:
I can get the second listbox to empty and add dummy data, but i can't figure out how to keep the array in memory. I'm getting confused, is this even possible?
where selectCtrl is the name of the second select. Can anybody suggest something?
The data is stored in a multidimentionnal array generated by php. The output looks something like this:
Code:
Array (
[Fruits] => Array ( [0] => Apples [1] => Bananas [2] => Oranges )
[Veggies] => Array ( [0] => Peas [1] => Carrots )
)
I can get the second listbox to empty and add dummy data, but i can't figure out how to keep the array in memory. I'm getting confused, is this even possible?
Code:
<script type="text/javascript" language="Javascript">
<!-- //
function update_list(myform, array_list)
{
myform.selectCtrl.length = 0;
myform.selectCtrl.options[0] = new Option ('Aucun','none');
for (var i = 1; i <= array_list.length; i++)
{
myform.selectCtrl.options[i] = new Option(array_list[i-1],array_list[i-1]);
}
}
// --></script>
where selectCtrl is the name of the second select. Can anybody suggest something?