function addt(){
var selVal = document.all.T5.value;
if(selVal == ""){
alert("没有选择");
return;
}
document.all.S1.value = document.all.S1.value + "\n" +selVal;
}
function delt(){
document.all.S1.value = "";
}
var selVal = document.all.T5.value;
if(selVal == ""){
alert("没有选择");
return;
}
document.all.S1.value = document.all.S1.value + "\n" +selVal;
}
function delt(){
document.all.S1.value = "";
}
var selVal = sel.options[sel.selectedIndex].innerText;
<html>
<head>
<script>
function addt(){
var sel = document.all.T5;
if(sel.selectedIndex==-1)
{
alert("没有选择");
return;
}
var selVal = sel.options[sel.selectedIndex].innerText;
document.all.S1.value = document.all.S1.value + "\n" +selVal;
}
function delt(){
document.all.S1.value = "";
}
</script>
</head>
<body>
<table cellpadding="0" cellspacing="0" width="461" height="108">
<tr>
<td valign="top" width="173"> <select size="7" id=T5 name="T5">
<option>11111111 </option>
<option>22222222 </option>
<option>33333333 </option>
<option>44444444 </option>
<option>55555555 </option>
<option>66666666 </option>
<option>77777777 </option>
<option>88888888 </option>
<option>99999999 </option>
</select> </td>
<td valign="top" height="108">
<input type="button" value="选择" name="B1" onclick="addt()"> <p>
<input type="button" value="取消" name="B2" onclick="delt()"> </td>
<td valign="top" width="248">
<textarea rows="8" name="S1" cols="20" id=MemoBox> </textarea> </td>
</tr>
</table>
</body>
用文本就算了
但是选择到文本区后,第一行是空白的,这么奇怪的??
<SCRIPT LANGUAGE="JavaScript">
function addt()
{
var t5 = document.getElementById("T5")
var s1 = document.getElementById("MemoBox")
if(t5.selectedIndex>-1)
s1.add(new Option(t5.options[t5.selectedIndex].text))
else
alert("没有选择");
}
function delt()
{
var s1 = document.getElementById("MemoBox")
if(s1.selectedIndex>-1)
s1.removeChild(s1.options[s1.selectedIndex])
}
</SCRIPT>
<table cellpadding="0" cellspacing="0" width="461" height="108">
<tr>
<td valign="top" width="173">
<select size="7" id=T5 name="T5">
<option>11111111 </option>
<option>22222222 </option>
<option>33333333 </option>
<option>44444444 </option>
<option>55555555 </option>
<option>66666666 </option>
<option>77777777 </option>
<option>88888888 </option>
<option>99999999 </option>
</select> </td>
<td valign="top" height="108">
<input type="button" value="选择" name="B1" onclick="addt()"> <p>
<input type="button" value="取消" name="B2" onclick="delt()"> </td>
<td valign="top" width="248">
<select size=7 name="S1" id=MemoBox style="width:100%"></select> </td>
</tr>
</table>
把下面这句
document.all.S1.value = document.all.S1.value + "\n" +selVal;
改成
document.all.S1.value = document.all.S1.value +selVal+ "\n";
就可以了