, , .
, , : , , - . jQuery <option> , , .
options = {
"one": [1, 2, 3, 4],
"two": [11, 12, 13, 14],
"three": [21, 22, 23, 24]
}
$("select.select1").change(function() {
var category = $(this).val() || $(this).text();
if (options[category]) {
$("select.select2").empty();
for (var i in options[category]) {
var newOption = $("<option>").text(options[category][i]);
$("select.select2").append(newOption);
}
} else {
$("select.select2").html("<option>Select a category first</option>");
}
});
$("select.select1").change();
HTML:
<select class="select1">
<option>one</option>
<option>two</option>
<option>three</option>
</select>
<select class="select2">
</select>