日期:2014-05-16  浏览次数:20393 次

(转)js实现多选
<title>无标题页</title>
    <script  type="text/javascript" src="pageScript.js"> </script>
    <script type="text/javascript">
   function open1(hiden){
       window.open("sub.aspx?hiden="+hiden,"newwindow","height=100,width=200,top=200,left=300");
    }
    //清除选择项
function Cel(_Value,showText,showValue)
{
    var Array_value = document.getElementById(showValue).value.split("|");
    var Array_text = document.getElementById(showText).innerHTML.split("|");
    var existed = 0;
    for(i=0;i < Array_value.length;i++){
      //  if(_Value.replace(/_/ig,"-")==Array_value[i].replace(/_/ig,"-"))
        {
            Realign(i,showText,showValue);
            break;
        }
    }
}
//重新排列选项
function Realign(value,showText,showValue){
    var Array_value = document.getElementById(showValue).value.split("|");
    var Array_text = document.getElementById(showText).innerHTML.split("|");
    Array_text[value]="";
    Array_value[value]="";
    document.getElementById(showText).innerHTML = "";
    document.getElementById(showValue).value = "";
    for(j=0;j<Array_text.length;j++){
        if(Array_text[j]!="")
            document.getElementById(showText).innerHTML +=Array_text[j]+"|";
    }
    for(e=0;e<Array_value.length;e++){
        if(Array_value[e]!="")
            document.getElementById(showValue).value +=Array_value[e]+"|";
    }
}
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="tb_usePeople" runat="server" Text="Label"></asp:Label>
        <asp:Button ID="Button1" runat="server" Text="Button" />
        <asp:HiddenField ID="HF_Value" runat="server" />
    </div>
    </form>
</body>
</html>

protected void Page_Load(object sender, EventArgs e)
    {
        //初始化有多少人
        string value = "";
        if(HF_Value.Value!=null)
            value=HF_Value.Value;
        if (!IsPostBack)
        {
            value = "qq|ww|yy|";
            HF_Value.Value = value;
        }
        tb_usePeople.Text = GetUsers(value, "tb_usePeople", "HF_Value");
            Button1.Attributes.Add("onclick","javascript:open1('"+value+"')");
    }
    public String GetU