I want to change the options of select2 based on the choice in select1. Therefore I made a associative array like this:
var rubrieken = {'1': '<option value="10">Rubriek 10</option><option value="20">Rubriek 20</option>','2': '<option value="30">Rubriek 30</option><option value="40">Rubriek 40</option>'};
So if in select1 option 2 is selected, the current values of select2 have to be replaced with the options with key 2. Im made the Jquery below, but how to extract the options from the array an put them in the select?
var rubrieken = {'1': '<option value="10">Rubriek 10</option><option value="20">Rubriek 20</option>','2': '<option value="30">Rubriek 30</option><option value="40">Rubriek 40</option>'};
$( document ).ready(function() {
//Bij keuze categorie de rubrieken vullen
$("#select1").change(function(){
//maak de huidige select leeg
$('#select2').empty();
//selectie uit array van juiste waarden
$newoptions = "<option>NewO1</option><option>NewO1</option>";
//vul de select rubriek op basis van categorie keuze
$('select#select2').html($newoptions);
});
});
options. is it 1 and 2 ?