关于如何动态地在同一页面实现两个 互传
2008-04-24 19:53
585 查看
关于如何动态地在同一页面实现两个<select>互传 (s1 <==> s2)
(jaklin )
hello! 先祝大家中秋节快乐!
我们常常会碰到这样一个问题: 如何将在同一页面上的一个<select>或<listbox>的值传到另一个<select>或<listbox>中 ?这是一个很烦人的问题。可是有时候你偏偏会遇到。 那什么办呢?
下面是我“烟酒”了一个上午, 现贴上来让大家共享。 用的方法是很笨也挺麻烦。不过总是有点成就感的。呵呵!大家看看, 指点指点.....
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<script language="vbscript">
</script>
<body bgcolor="#ffffff">
<form name="form1" action="test01.asp" target="_self">
<p><TEXTAREA id=text01 name=text01></TEXTAREA></p>
<table>
<tr>
<td>
<select name="select1" language="javascript" size=5>
<option value=11111>11111</option>
<option value=22222>22222</option>
<option value=33333>33333</option>
</select>
</td>
<td>
<label onClick=do_select()><font color=#ff00dc><u>->> </u></font> </label><br><br>
<label onClick=do_select2()><font color=#ff00dc><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&_ "document.form1.sel2.options[document.form1.sel2.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><select id=sel2 name=sel2 size=5>"
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
Response.Write "<SCR"& "IPT LANGUAGE=""JavaScript"">" & vbCrlf
Response.Write str & vbCrlf & "</SCR"&"IPT>"& vbCrlf
%>
<%
str=""
str="function do_select2() {" & vbCrlf & _
"if (document.form1.sel2.options.length > 0) {"&vbCrlf&_
"var j=0;"&vbCrlf&_
"for(var i=0;i<document.form1.sel2.options.length;i++) {"&vbCrlf & _
"if(document.form1.sel2.options(i).selected) {"&vbCrlf& _
"j=j+1; break" & vbCrlf & "}"&vbCrlf & "}"&vbCrlf& _
"if (j > 0) {"&vbCrlf&_
"document.form1.select1.options[document.form1.select1.options.length] = new Option(" & _
"document.form1.sel2.options[document.form1.sel2.selectedIndex].value," & _
"document.form1.sel2.options[document.form1.sel2.selectedIndex].value);"& vbCrlf
str=str&"document.form1.sel2.options[document.form1.sel2.selectedIndex] =null;" & vbCrlf &"}"& vbCrlf &"}"& vbCrlf &"}"
Response.Write "<SCR"& "IPT LANGUAGE=""JavaScript"">" & vbCrlf
Response.Write str & vbCrlf & "</SCR"&"IPT>"& vbCrlf
%>
</tr>
</table>
</form>
</body>
</HTML>
(jaklin )
hello! 先祝大家中秋节快乐!
我们常常会碰到这样一个问题: 如何将在同一页面上的一个<select>或<listbox>的值传到另一个<select>或<listbox>中 ?这是一个很烦人的问题。可是有时候你偏偏会遇到。 那什么办呢?
下面是我“烟酒”了一个上午, 现贴上来让大家共享。 用的方法是很笨也挺麻烦。不过总是有点成就感的。呵呵!大家看看, 指点指点.....
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<script language="vbscript">
</script>
<body bgcolor="#ffffff">
<form name="form1" action="test01.asp" target="_self">
<p><TEXTAREA id=text01 name=text01></TEXTAREA></p>
<table>
<tr>
<td>
<select name="select1" language="javascript" size=5>
<option value=11111>11111</option>
<option value=22222>22222</option>
<option value=33333>33333</option>
</select>
</td>
<td>
<label onClick=do_select()><font color=#ff00dc><u>->> </u></font> </label><br><br>
<label onClick=do_select2()><font color=#ff00dc><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&_ "document.form1.sel2.options[document.form1.sel2.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><select id=sel2 name=sel2 size=5>"
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
Response.Write "<SCR"& "IPT LANGUAGE=""JavaScript"">" & vbCrlf
Response.Write str & vbCrlf & "</SCR"&"IPT>"& vbCrlf
%>
<%
str=""
str="function do_select2() {" & vbCrlf & _
"if (document.form1.sel2.options.length > 0) {"&vbCrlf&_
"var j=0;"&vbCrlf&_
"for(var i=0;i<document.form1.sel2.options.length;i++) {"&vbCrlf & _
"if(document.form1.sel2.options(i).selected) {"&vbCrlf& _
"j=j+1; break" & vbCrlf & "}"&vbCrlf & "}"&vbCrlf& _
"if (j > 0) {"&vbCrlf&_
"document.form1.select1.options[document.form1.select1.options.length] = new Option(" & _
"document.form1.sel2.options[document.form1.sel2.selectedIndex].value," & _
"document.form1.sel2.options[document.form1.sel2.selectedIndex].value);"& vbCrlf
str=str&"document.form1.sel2.options[document.form1.sel2.selectedIndex] =null;" & vbCrlf &"}"& vbCrlf &"}"& vbCrlf &"}"
Response.Write "<SCR"& "IPT LANGUAGE=""JavaScript"">" & vbCrlf
Response.Write str & vbCrlf & "</SCR"&"IPT>"& vbCrlf
%>
</tr>
</table>
</form>
</body>
</HTML>
相关文章推荐
- 教你如何实现 Splash 页面三秒跳转和动态下载最新背景图
- 如何实现服务器端下页面动态添加JavaScript脚本
- 关于在使用iframe之后子页面中如何在父级弹窗的问题的具体实现
- 如何实现两个页面的跳转
- 如何实现两个页面之间进行传值
- android开发游记:酷炫的启动页面之如何实现两个ViewPager的联动
- ios 关于如何在两个页面间传值
- 如何实现页面时间实时动态更新(局部更新)
- 把页面分成左右两个,如何实现在左侧点击,链接一个页面到右边的页面
- 不刷新页面动态更新select选项,实现两个select相互操作
- 如何在页面上动态实现浮动窗口?
- 页面使用iframe进行嵌套,关于如何实现,在子页面使整个页面跳转到其他页面
- 关于Oracle组件如何正确实现动态Web的数据库
- 【原】关于如何在Master Page中实现当前激活项与页面相对应
- 如何实现从服务器端向页面动态加载JavaScript脚本?
- 关于两个Activity实现页面跳转问题
- 关于如何实现在整合struts2和hibernate4框架下实现many-to-one级联数据表在JSP页面中的输出
- 如何实现服务器端下页面动态添加JavaScript脚本
- 如何实现服务器端下页面动态添加JavaScript脚本
- 如何实现同一个页面里面两个页面的相互切换(window.onscroll)