I am just missing something.
Very simple or so I thought - using jquery - Based on the value selected in the Workers dropdown, I want to display on
Do something like this:
var data = [ // The data ['Roy', [ 'Apples','Peaches' ]], ['John', [ 'Oranges', 'Pears', 'Peaches', 'Nuts' ]] ]; $a = $('#worker'); // The dropdowns $b = $('#fruits'); for(var i = 0; i < data.length; i++) { var first = data[i][0]; $a.append($(""). // Add options attr("value",first). data("sel", i). text(first)); } $a.change(function() { var index = $(this).children('option:selected').data('sel'); var second = data[index][1]; // The second-choice data $b.html(''); // Clear existing options in second dropdown for(var j = 0; j < second.length; j++) { $b.append($(""). // Add options attr("value",second[j]). data("sel", j). text(second[j])); } }).change(); // Trigger once to add options at load of first choice
http://jsfiddle.net/xRTAk/