<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
</head><body>
<script>
function setselect(obj){
myselected.value+=obj.options[obj.selectedIndex].value;
obj.options[obj.selectedIndex]=null
}
</script>
<select name=myselect onchange="setselect(this)">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5>5</option>
<option value=6>6</option>
</select>
<textarea id=myselected name=myselected></textarea>
</body></html>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
</head><body>
<script>
function setselect(obj){
myselected.value+=obj.options[obj.selectedIndex].value;
obj.options[obj.selectedIndex]=null
}
</script>
<select name=myselect onchange="setselect(this)">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5>5</option>
<option value=6>6</option>
</select>
<textarea id=myselected name=myselected></textarea>
</body></html>
1,如何能显示text,而不是value。例子里,text是11,22,33什么的,选择后显示的是value,1,2,3什么的,怎么改?
2,我添加了删除的功能,如何删除后,条目又在下拉菜单里显示出来?
<script language="javascript"> function setselect(obj){
var tab = document.getElementById('my_table');
var tr = tab.insertRow(); tr.id=obj.options[obj.selectedIndex].value;
var td = tr.insertCell(); td.innerHTML = obj.options[obj.selectedIndex].value;
var td = tr.insertCell(); td.innerHTML = '<a href="javascript:loeschenrow('+obj.options[obj.selectedIndex].value+');" ><img src="button_drop.png" alt="del" align="middle" name="saveWorker" border="0" />';
obj.options[obj.selectedIndex]=null;
}
function loeschenrow(obj){
alert(obj);
document.getElementById(obj).style.display='none'; }
</script> <table border=1 id="my_table">
</table><select name=myselect onchange="setselect(this)">
<option value=0>---</option>
<option value=1>11</option>
<option value=2>22</option>
<option value=3>33</option>
<option value=4>44</option>
<option value=5>55</option>
<option value=6>66</option>
</select>