Sagen, ich habe diesen Drop-Down:jQuery SELECT Optionen entfernen auf einem anderen Basis SELECT ausgewählt (Unterstützung für alle Browser benötigt)
<select id="theOptions1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
Ich will es so, dass, wenn der Benutzer 1 wählt, ist dies die Sache, dass der Benutzer
<select id="theOptions2">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>
Oder wenn der Benutzer: 2: 2 kann für Drop-Down wählen
<select id="theOptions2">
<option value="a">a</option>
<option value="b">b</option>
</select>
oder wenn der Benutzer sele 3 cts:
<select id="theOptions2">
<option value="b">b</option>
<option value="c">c</option>
</select>
Ich habe versucht, den Code hier gepostet: jQuery disable SELECT options based on Radio selected (Need support for all browsers)
Aber es funktioniert nicht für wählt.
Bitte helfen! Vielen Dank!
UPDATE: Ich mag die Antwort Paolo Bergantino auf hatte: jQuery disable SELECT options based on Radio selected (Need support for all browsers)
Gibt es das überhaupt zu ändern, mit wählen Tasten statt Radio zu arbeiten?
jQuery.fn.filterOn = function(radio, values) {
return this.each(function() {
var select = this;
var options = [];
$(select).find('option').each(function() {
options.push({value: $(this).val(), text: $(this).text()});
});
$(select).data('options', options);
$(radio).click(function() {
var options = $(select).empty().data('options');
var haystack = values[$(this).attr('id')];
$.each(options, function(i) {
var option = options[i];
if($.inArray(option.value, haystack) !== -1) {
$(select).append(
$('<option>').text(option.text).val(option.value)
);
}
});
});
});
};
Ich werde das jetzt versuchen. Ich mag es, wie Sie die Benutzeroberfläche schön halten – Oscar
Dieses Beispiel von Ihnen gespeichert mir einen Tag Arbeit. Vielen Dank! –