| 网站首页 | 硬件维修 | 应用学院 | 网络组建 | 网站制作 | 菜鸟黑客 | 编程之道 | 数码大全 | 娱乐休闲 | 软件下载 | 在线视频 | 请您留言 | 技术论坛 | 
专 题 栏 目
最 新 热 门
最 新 推 荐
相 关 文 章
  • 用javascript实现利用FL…

  • javascript实例教程(20)…

  • HTML页面如何象asp一样接受参…

  • 如何实现iframe(嵌入式帧)的…

  • 将金额小写转化成汉字大写的…

  • 用JavaScrpt实现文件夹轻松加…

  • 完美解决一个事件激活多个函…

  • 用javascript实现浏览器…

  • 如何制作浮动广告

  • 用javascript绘图—JS2D…

  • Q
    您现在的位置: 我是IT人 >> 网站制作 >> ASP >> 文章正文
    关于如何动态地在同一页面实现两个互传(s1 s2)         
    关于如何动态地在同一页面实现两个互传(s1 s2)
    作者:网络 文章来源:转载 点击数: 更新时间:2005-9-30
    [ 字体:缩小 正常 放大 | 双击自动滚屏 ]
    请选择合适的字体颜色:


    我们常常会碰到这样一个问题: 如何将在同一页面上的一个<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>

    [1] [2] 下一页  

    文章录入:小秦    责任编辑:小秦 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    | 设为首页 | 加入收藏 | 联系站长 | 关于我们 | 友情链接 | 版权申明 |