社区
ASP
帖子详情
在线等待,急!!
dsppcn
2003-11-11 11:32:49
如何在下拉框中(从数据库取出数据),选择一个内容,然后添加到文本框,然后再选,在添加到文本框,中间用分号分开,然后,对文本框中的内容进行分离,最后,对每个下拉框的内容添加相同的信息,如何处理呢?(vbscripit + sqlserver2000)
...全文
75
2
打赏
收藏
在线等待,急!!
如何在下拉框中(从数据库取出数据),选择一个内容,然后添加到文本框,然后再选,在添加到文本框,中间用分号分开,然后,对文本框中的内容进行分离,最后,对每个下拉框的内容添加相同的信息,如何处理呢?(vbscripit + sqlserver2000)
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
jacklinchen
2003-11-11
打赏
举报
回复
2。修改时,从表中调出其值, 通过split()进行分解, 然后放在下拉框中, 功能是一样的, 可增可删, 代码为:
<TD align=right width=220>
<select name="select1" size=10 style="width:240">
<option value="" disabled>====== 待选国家(地区) ======</option>
<%
dim rsc
set rsc=server.CreateObject("adodb.recordset")
sql=""
sql="select * from tbCountryInfo order by CountryID"
rsc.Open sql,conn,1,1
do while not rsc.EOF
ExAreas=split(rs("ImportedArea"),",")
i=0
for each ExArea2 in ExAreas
if trim(ExArea2)<>"" then
i=i+1
set rsa1=server.CreateObject("adodb.recordset")
sql=""
sql="select * from tbCountryInfo where CountryID="&cint(ExArea2)
rsa1.Open sql,conn,1,1
ExArea3=ExArea3&","&rsa1("CountryID")&" "&rsa1("CountryCnName")
end if
next
if instr(1,ExArea3,cstr(rsc("CountryID"))&" "&trim(rsc("CountryCnName")))<1 then
%>
<option value="<%=cstr(rsc("CountryID"))&" "&trim(rsc("CountryCnName"))%>"><%=cstr(rsc("CountryID"))&" "&trim(rsc("CountryCnName"))%></option>
<%
end if
rsc.MoveNext
loop
rsc.Close
set rsc=nothing
%>
</select>
</td>
<td width="80" align=center>
<label onClick="do_select()" style="cursor:hand"><font color="blue"><u>加---></u></font></label><br><br><br>
<label onClick="do_select2()" style="cursor:hand"><font color="blue"><u><---删</u></font></label>
</td>
<TD align=right width=190>
<select name="SelCountrys" size=10 style="width:240">
<option value="" disabled>====== 已选国家(地区) ======</option>
<%
ExArea=split(rs("ImportedArea"),",")
ImportedArea_o=""
i=0
for each ExArea1 in ExArea
if trim(ExArea1)<>"" then
i=i+1
set rsa=server.CreateObject("adodb.recordset")
sql=""
sql="select * from tbCountryInfo where CountryID="&cint(ExArea1)
rsa.Open sql,conn,1,1
ImportedArea_o=ImportedArea_o&","&rsa("CountryID")&" "&rsa("CountryCnName")
%>
<option value="<%=rsa("CountryID")&" "&rsa("CountryCnName")%>"><%=rsa("CountryID")&" "&rsa("CountryCnName")%></option>
<% rsa.Close
end if
next
%>
</select>
</td>
<%
str=""
str="function do_select() {" & vbCrlf & _
"if (document.form1.select1.options.length > 0) {"&vbCrlf&_
"var j=0;"&vbCrlf&_
"for(var i=0;i<document.form1.select1.options.length;i++) {"&vbCrlf & _
"if(document.form1.select1.options(i).selected) {"&vbCrlf& _
"j=j+1; break" & vbCrlf & "}"&vbCrlf & "}"&vbCrlf& _
"if (j > 0) {"&vbCrlf&_
"if (document.form1.select1.options[document.form1.select1.selectedIndex].value!='') {"&vbCrlf & _
"document.form1.SelCountrys.options[document.form1.SelCountrys.options.length] = new Option(" & _
"document.form1.select1.options[document.form1.select1.selectedIndex].value," & _
"document.form1.select1.options[document.form1.select1.selectedIndex].value);"& vbCrlf
str=str&"document.form1.select1.options[document.form1.select1.selectedIndex] =null;" & vbCrlf &"}"& vbCrlf '&"}"& vbCrlf ' &"}"
str=str&"document.form1.ImportedArea.value=''" &vbCrlf
str=str&" for(var i=0;i<document.form1.SelCountrys.options.length;i++) {"&vbCrlf & _
" document.form1.ImportedArea.value=document.form1.ImportedArea.value+','+document.form1.SelCountrys.options[i].value}"&"}"& vbCrlf &vbCrlf &"}"&vbCrlf &"}"
Response.Write "<SCR"& "IPT LANGUAGE=""JavaScript"">" & vbCrlf
Response.Write str & vbCrlf & "</SCRIPT>"& vbCrlf
%>
<%
str=""
str="function do_select2() {" & vbCrlf & _
"if (document.form1.SelCountrys.options.length > 0) {"&vbCrlf&_
"var j=0;"&vbCrlf&_
"for(var i=0;i<document.form1.SelCountrys.options.length;i++) {"&vbCrlf & _
"if(document.form1.SelCountrys.options(i).selected) {"&vbCrlf& _
"j=j+1; break" & vbCrlf & "}"&vbCrlf & "}"&vbCrlf& _
"if (j > 0) {"&vbCrlf&_
"if (document.form1.SelCountrys.options[document.form1.SelCountrys.selectedIndex].value !='') {"&vbCrlf&_
"document.form1.select1.options[document.form1.select1.options.length] = new Option(" & _
"document.form1.SelCountrys.options[document.form1.SelCountrys.selectedIndex].value," & _
"document.form1.SelCountrys.options[document.form1.SelCountrys.selectedIndex].value);"& vbCrlf
'str=str&"if (len=document.form1.ImportedArea.indexOf(1,document.form1.SelCountrys.options[document.form1.SelCountrys.selectedIndex].value)>0) {"& vbCrlf & _
' "document.form1.ImportedArea.value=document.form1.ImportedArea.substr(1,len)+document.form1.ImportedArea.substr(len+document.form1.SelCountrys.options[document.form1.SelCountrys.selectedIndex].length); }"& vbCrlf
str=str&"document.form1.SelCountrys.options[document.form1.SelCountrys.selectedIndex] =null;" & vbCrlf &"}"& vbCrlf '&"}"& vbCrlf ' &"}"
str=str&"document.form1.ImportedArea.value=''" &vbCrlf
str=str&" for(var i=0;i<document.form1.SelCountrys.options.length;i++) {"&vbCrlf & _
"if (document.form1.SelCountrys.options[i].value !='') {"&vbCrlf & _
" document.form1.ImportedArea.value=document.form1.ImportedArea.value+','+document.form1.SelCountrys.options[i].value}"&"}"& vbCrlf &vbCrlf &"}"&vbCrlf &"}"&vbCrlf &"}"
Response.Write "<SCR"& "IPT LANGUAGE=""JavaScript"">" & vbCrlf
Response.Write str & vbCrlf & "</SCRIPT>"& vbCrlf
%>
jacklinchen
2003-11-11
打赏
举报
回复
我是这样做的, 就是用两个下拉框, 然后在两个下拉框中可自由选择、删除,然后将选中的项目放到隐藏的文本框中。 很方便的, 由于代码较长, 得分成两个贴子了。
1。 增加时:
<TD align=right width=240>
<select name="select1" size=10 style="width:220">
<option value="" disabled>====== 待选国家(地区) ======</option>
<%
dim rsc
set rsc=server.CreateObject("adodb.recordset")
sql=""
sql="select * from tbCountryInfo order by CountryID"
rsc.Open sql,conn,1,1
do while not rsc.EOF
%>
<option value="<%=cstr(rsc("CountryID"))&" "&trim(rsc("CountryCnName"))%>"><%=cstr(rsc("CountryID"))&" "&trim(rsc("CountryCnName"))%></option>
<%
rsc.MoveNext
loop
rsc.Close
set rsc=nothing
%>
</select>
</td>
<td width="80" align=center>
<label onClick="do_select()" style="cursor:hand"><font color="blue"><u>加--></u></font></label><br><br><br>
<label onClick="do_select2()" style="cursor:hand"><font color="blue"><u><--删</u></font></label>
</td>
<%
str="function do_select() {" & vbCrlf & _
"if (document.form1.select1.options.length > 0) {"&vbCrlf&_
"var j=0;"&vbCrlf & _
"for(var i=0;i<document.form1.select1.options.length;i++) {"&vbCrlf & _
"if(document.form1.select1.options(i).selected) {"&vbCrlf& _
"j=j+1; break" & vbCrlf & "}"&vbCrlf & "}"&vbCrlf& _
"if (j > 0) {"&vbCrlf & _
"if (document.form1.select1.options[document.form1.select1.selectedIndex].value!='') {"&vbCrlf & _
"document.form1.SelCountrys.options[document.form1.SelCountrys.options.length] = new Option(" & _
"document.form1.select1.options[document.form1.select1.selectedIndex].value," & _
"document.form1.select1.options[document.form1.select1.selectedIndex].value);"& vbCrlf '& _
Response.Write "<td align=center><SELECT id=SelCountrys name=SelCountrys size=10 style='width:220'><option value='' disabled> ====== 已选国家(地区) =====</option>"
Response.Write "</select></td>"
str=str&vbCrlf&"document.form1.select1.options[document.form1.select1.selectedIndex]=null;"&vbCrlf & _
"if (document.form1.select1.options.length > 1) {"&vbCrlf
str=str&vbCrlf & "}" & vbCrlf & "}" & vbCrlf & "}" & vbCrlf& "}" & vbCrlf '& "}" & vbCrlf
str=str&"document.form1.ImportedArea.value='';"&vbCrlf & _
"for(var i=0;i<document.form1.SelCountrys.options.length;i++) {"&vbCrlf & _
"if (document.form1.SelCountrys.options[i].value !='') {"&vbCrlf & _
" document.form1.ImportedArea.value=document.form1.ImportedArea.value+','+document.form1.SelCountrys.options[i].value}"&vbCrlf &"}" &vbCrlf &"}"
Response.Write "<SCR"& "IPT LANGUAGE=""JavaScript"">" & vbCrlf
Response.Write str & vbCrlf & "</SCRIPT>"& vbCrlf
%>
<%
str=""
str="function do_select2() {" & vbCrlf & _
"if (document.form1.SelCountrys.options.length > 0) {"&vbCrlf&_
"var j=0;"&vbCrlf&_
"for(var i=0;i<document.form1.SelCountrys.options.length;i++) {"&vbCrlf & _
"if(document.form1.SelCountrys.options(i).selected) {"&vbCrlf& _
"j=j+1; break" & vbCrlf & "}"&vbCrlf & "}"&vbCrlf& _
"if (j > 0) {"&vbCrlf&_
"if (document.form1.SelCountrys.options[document.form1.SelCountrys.selectedIndex].value !='') {"&vbCrlf&_
"document.form1.select1.options[document.form1.select1.options.length] = new Option(" & _
"document.form1.SelCountrys.options[document.form1.SelCountrys.selectedIndex].value," & _
"document.form1.SelCountrys.options[document.form1.SelCountrys.selectedIndex].value);"& vbCrlf
str=str&"document.form1.SelCountrys.options[document.form1.SelCountrys.selectedIndex] =null;" & vbCrlf &"}" & vbCrlf &"}"& vbCrlf &"}"& vbCrlf '&"}"
str=str&"document.form1.ImportedArea.value='';"&vbCrlf & _
"for(var i=0;i<document.form1.SelCountrys.options.length;i++) {"&vbCrlf & _
"if (document.form1.SelCountrys.options[i].value !='') {"&vbCrlf & _
" document.form1.ImportedArea.value=document.form1.ImportedArea.value+','+document.form1.SelCountrys.options[i].value}"&vbCrlf &"}" &vbCrlf &"}"
Response.Write "<SCR"& "IPT LANGUAGE=""JavaScript"">" & vbCrlf
Response.Write str & vbCrlf & "</SCRIPT>"& vbCrlf
%>
急
!求救!!!请教关于sql server启动的问题
请教各位大侠,为何我的SQL SERVER 2000个人版启动后,不断耗用内存,但又无法打开数据库,奇怪!
在线
等待
!
急
!
运动会计算机专业方队,求运动会入场式创意。要低成本的最好。我是计算机专业的。
急
!
在线
等,高悬赏!...
急
!
在线
等,高悬赏!以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!求运动会入场式创意。要低成本的最好。我是计算机专业的。
急
!
在线
等,高悬赏!...
关于读取Excel表中数据的问题!!!
急
急
急
!!我用,Excel的com写了,读取excel的程序.已经取得了当前的worksheet,我现在想要取当前worksheet中一共有多少行,多少列,就没办法了.........请各位帮帮我啊!!谢谢了
在线
等待
!!小小良 2007-9-5 18:12遍历行列,...
急
!求各位学长大佬拯救!!
求各位学长大佬们帮帮忙!!小生拜谢! 本人是一名专科大二的学生,在学的语言是C#,自己也自学了一点Java基础。在网上看了很多的帖子什么的,越看越对C#的前景不看好,感觉以后的工资和工作机会都不如Java程序员,...
关于手机网站的管理~~~~~
急
!
在线
等待
~~~
各位高手,我是一个菜鸟级人物,不过打算管理一个有关手机的网站,但我不知道这个是否很难,请问有关这方面的网站,大家有没有做过,请教一下。1、怎样进入这种网站的后台管理。2、这种网站是否复杂。...
ASP
28,406
社区成员
356,946
社区内容
发帖
与我相关
我的任务
ASP
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
复制链接
扫一扫
分享
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章