Ich habe diesen Code zum Hinzufügen neuer Wert in Combobox verwendet, mein Problem ist, wie werde ich jeden hinzugefügten Wert wie ausgewählt?standardmäßig ausgewählte Combobox in Mehrwert
<legend>Combo box</legend>
Add to Combo: <input type="text" name="txtCombo" id="txtCombo"/>
<input type="button" value="Add" onclick="addCombo()">
<br/>
Combobox: <select name="combo" multiple id="combo"></select>
</fieldset>
</BODY>
</HTML>
<script>
function addCombo() {
var textb = document.getElementById("txtCombo");
var combo = document.getElementById("combo");
var option = document.createElement("option");
option.text = textb.value;
option.value = textb.value;
option.value = textb.value;
try {
combo.add(option, null); //Standard
}catch(error) {
combo.add(option); // IE only
}
textb.value = "";
}
</script>
Warum jquery-Tag zu Ihrer Frage haben Sie hinzufügen? Es ist nur JavaScript – Mojtaba