<select id="sel" style="width:200px;" size="10">
<option>11</option>
<option>22</option>
<option>33</option>
</select>
<input type="text" id="nr" />
<input type="button" value="添加" id="btn1" onclick="Add()" />
<script type="text/javascript">
function Add()
{
//取出用户输入的值
var v = document.getElementById("nr").value;
//向列表里面添加
var list = document.getElementById("sel");
list.innerHTML += "<option>"+v+"</option>";
alert(document.getElementById("sel").value);
}
</script>
时间: 2024-10-27 13:17:38