我想从文本框中获取值
并将其添加到另一页的下拉列表中。
答案 0 :(得分:1)
假设您有以下两种形式:
<form id="form1">
<input type="text" value="testing">
<button id="addoption">Click on me</button>
</form>
<form id="form2">
<select name="myoptions" id="myselect">
<option value="1">first option</option>
</select>
</form>
$('#addoption').click(function(e){
e.preventDefault(); //Prevent to send the form
var myvalue = $('input').val();
//Now let's append an option to the select
$('#myselect').append($("<option></option>").text(myvalue));
});