[求助]请教如何在选择转换时文本框内容不被清除-->lmhllr转移
我的程序如下:这程序有问题,即把“选择一”的选项加入文本框,后点击“选择二”时,我的愿望要保留在文本框原先的内容,再在其后加一“选择二”的选项。但点击“选择二”时,文本框原先内容被清除了,只能加入“选择二”的选项。请教有什么方法能使在“选择一”和“选择二”之间切换时能保留文本框的原先内容,即文本框的原先内容不被清除。
<%
Set rs = Server.CreateObject("ADODB.Recordset")
xhm=request.form("xhh")
bj=4
sql="select * from g1bgd where len(rtrim(xh))='3'and left(rtrim(XH),1)='"&bj&"'"
rs.open sql,conn,1,3
bt=request.querystring("s")
if bt="" then
bt="ztyx"
end if
Set xs = Server.CreateObject("ADODB.Recordset")
sql="select "&bt&" from [bzrpy] "
xs.open sql,conn,1,1
%>
<body>
<%
pgsize=1
page=request.querystring("page")
rs.pagesize=pgsize
pgnm=rs.pagecount
if page=""or clng(page)<1 then page=1
if clng(page)>pgnm then page=pgnm
if pgnm>0 then rs.absolutepage=page
count=0
do while not xs.eof and count<xs.pagesize
%>
<script language="javascript">
function addnew()
{ if(checked_check("s1") != true)
{ alert("Please s1 a option!");
return false; }
var t=document.all.s1;
var text=t.options[t.selectedIndex].innerText;
var value=t.options[t.selectedIndex].value;
form1.text2.value=form1.text2.value+value
t.selectedIndex = 0;
}
function checked_check(idname)
{
var checkobject = document.getElementById(idname);
var coun = checkobject.length;
for(i=0;i<coun;i++)
{
if(checkobject.options[i].selected == true)
return true; }
return false;}
</script>
<form id="form1" name="form1" method="post" action="">
<table width="500" border="0" align="center">
<tr>
<td colspan="3"><p><a href=zs.asp?s=<%="ztyx"%>>选择一</a> <a href=zs.asp?s=<%="sk"%>>选择二</a> </p></td>
</tr>
<tr>
<td width="281"><select name="select" size="6" id="s1">
<%
while not xs.eof
%>
<option value=<%=xs.fields.Item(bt).Value%>><%=xs.fields.Item(bt).Value%></option>
<%
xs.movenext
wend
%>
</select></td>
<td><div align="center">
<input type="button" name="Submit3" onclick="addnew()" value=">" />
</div></td>
<td><label>
<textarea name="text2" cols="40" rows="6" id="s2"></textarea>
</label></td>
</tr>
</table>
</form>
<div align="center">
<%count=count+1
rs.movenext
loop
%>
<a href=zs.asp?page=1>第一页</a>
<a href=zs.asp?page=<%=pgnm%>>最末页</a>
<a href=zs.asp?page=<%=page+1%>>下一页</a>
<a href=zs.asp?page=<%=page-1%>>上一页</a>
</div>
</body>
<%
Set rs = Server.CreateObject("ADODB.Recordset")
xhm=request.form("xhh")
bj=4
sql="select * from g1bgd where len(rtrim(xh))='3'and left(rtrim(XH),1)='"&bj&"'"
rs.open sql,conn,1,3
bt=request.querystring("s")
if bt="" then
bt="ztyx"
end if
Set xs = Server.CreateObject("ADODB.Recordset")
sql="select "&bt&" from [bzrpy] "
xs.open sql,conn,1,1
%>
<body>
<%
pgsize=1
page=request.querystring("page")
rs.pagesize=pgsize
pgnm=rs.pagecount
if page=""or clng(page)<1 then page=1
if clng(page)>pgnm then page=pgnm
if pgnm>0 then rs.absolutepage=page
count=0
do while not xs.eof and count<xs.pagesize
%>
<script language="javascript">
function addnew()
{ if(checked_check("s1") != true)
{ alert("Please s1 a option!");
return false; }
var t=document.all.s1;
var text=t.options[t.selectedIndex].innerText;
var value=t.options[t.selectedIndex].value;
form1.text2.value=form1.text2.value+value
t.selectedIndex = 0;
}
function checked_check(idname)
{
var checkobject = document.getElementById(idname);
var coun = checkobject.length;
for(i=0;i<coun;i++)
{
if(checkobject.options[i].selected == true)
return true; }
return false;}
</script>
<form id="form1" name="form1" method="post" action="">
<table width="500" border="0" align="center">
<tr>
<td colspan="3"><p><a href=zs.asp?s=<%="ztyx"%>>选择一</a> <a href=zs.asp?s=<%="sk"%>>选择二</a> </p></td>
</tr>
<tr>
<td width="281"><select name="select" size="6" id="s1">
<%
while not xs.eof
%>
<option value=<%=xs.fields.Item(bt).Value%>><%=xs.fields.Item(bt).Value%></option>
<%
xs.movenext
wend
%>
</select></td>
<td><div align="center">
<input type="button" name="Submit3" onclick="addnew()" value=">" />
</div></td>
<td><label>
<textarea name="text2" cols="40" rows="6" id="s2"></textarea>
</label></td>
</tr>
</table>
</form>
<div align="center">
<%count=count+1
rs.movenext
loop
%>
<a href=zs.asp?page=1>第一页</a>
<a href=zs.asp?page=<%=pgnm%>>最末页</a>
<a href=zs.asp?page=<%=page+1%>>下一页</a>
<a href=zs.asp?page=<%=page-1%>>上一页</a>
</div>
</body>