经典js代码 实现动态传值 实现动态页面传值 options动态显示数据


<html>
<head>
<title>
Vol_Outlay_ChooseSure
</title>
<link href="../css/index.css" rel="stylesheet" type="text/css"/>
</head>
<body bgcolor="#ffffff" onLoad="removeOption(SelectedItem);">
<table width="80%" height="47%" border="1" cellpadding="0" cellspacing="0" align="center">
        <tr>
          <td width="25%" height="34" align="right" valign="bottom" class="text">选择组</td>
    <td width="12%" height="34" align="right" valign="bottom" class="text">&nbsp;</td>

          <td width="%" height="34" align="center" valign="bottom" class="text">未选人员</td>
    <td width="12%">&nbsp;</td>
          <td width="25%" valign="bottom" class="text">已选人员</td>
        </tr>
        <tr><td>&nbsp;</td><td>&nbsp;</td>
  
          <td height="162" align="" valign="top">
            <select name="SelectedItem" style="width:100%" id="SelectedItem" size="12" multiple="true">
              <option>姚明</option>
              <option>刘翔</option>
            <option>李小双</option>
              <option>刘德华</option>
            <option>黎明</option>
              <option>张学友</option>
            <option>王晶</option>
              <option>张艺谋</option>
            <option>郑秀文</option>
              <option>杰克逊</option>
           
               
            
            </select>
          </td>
          <td  align="center" valign="top"><br/>
            <br/>
            <br/>
            <br/>
            <button onClick="MoveSingleItem(WaitSelectItem, SelectedItem)" class="bn">&lt;&lt;</button>
            <br/>
            <br/>
            <br/>
            <button onClick="MoveSingleItem(SelectedItem, WaitSelectItem)" class="bn">&gt;&gt;</button></td>

          <td valign="top"><select name="WaitSelectItem" style="width:100%" size=12 multiple="true">
            </select></td>
        </tr>

  <tr>

   <td align="center" colspan="5">&nbsp;</td>
  </tr>

 

  <tr>

   <td align="center" colspan="5">
   <input type="button" name="chooseOk" class="bn" value="确&nbsp;定" onClick="re(WaitSelectItem);"/>&nbsp;&nbsp;&nbsp;
      <input type="button" name="reset" class="bn" value="取&nbsp;消" onClick="javascript:window.close();"/></td>
  </tr>
      </table>
</body>
</html>

<script language="javascript" type="text/javascript">
   function MoveSingleItem(sel_source, sel_dest){
     if (sel_source.selectedIndex==-1){
       if(sel_source.options.length>0){
      var SelectedText = sel_source.options[sel_source.options.length-1].text;
    var objItemValue = sel_source.options[sel_source.options.length-1].value;
       sel_source.options.remove(sel_source.options.length-1);
           sel_dest.options.add(new Option(SelectedText,objItemValue));
    }

  }else{
   for(var i = sel_source.options.length-1; i >= 0; i--){
   if (sel_source.options[i].selected == true) {
    var SelectedText = sel_source.options[i].text;
    var objItemValue = sel_source.options[i].value;
    sel_source.options.remove(i);
    sel_dest.options.add(new Option(SelectedText,objItemValue));
   }
    }
   }
   }

   function re(sel_dest){
     window.returnValue=getSelectedValue(sel_dest);
  window.close();
   }

   function getSelectedValue(sel_dest){
     var arr = new Array();
     for(var i = sel_dest.options.length-1; i >= 0; i--){
   arr[i] = sel_dest.options[i].value;
  }
  return arr;
   }

   function removeOption(sel){
    sel.options.remove(0);
   }
</script>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值