<script>
function check(){
var cidx="";
for(i=0;i<add.cid.length;i++)
  {if (add.cid[i].checked)
   cidx+=document.add.cid[i].value;
   return cidx;
  }
  
}function doMDb(url)
{
var cidx=add.cid.value;
window.showModalDialog("selectb.jsp?cid="+checked()+"",window,'scroll:0;status:0;help:0;resizable:0;dialogWidth:480px;dialogHeight:370px');
return false;
}
</script>
<form action="#" name="add" method="post">
<input type="checkbox" name="cid" value=1>张三
<input type="checkbox" name="cid" value=2>李四
<input type="checkbox" name="cid" value=3>王五
<input type="checkbox" name="cid" value=4>赵六
<input type="checkbox" name="cid" value=5>曾七
<input type="button" name="B1" value="提交" onclick=check()>
</form>

解决方案 »

  1.   

    怎么办?
    HueVan() 兄弟,这种方法只能获得第一个input的值啊。
    就是说,无论你选几个,都只显示第一个的值。
      

  2.   

    wtoeb, your checkboxes don't have values, HueVan's method logically works, but adding value together is a bad idea, he should do something like<script>
    function check(){
    var a = new Array();
    var cidx="";
    for(i=0;i<add.cid.length;i++)
      {
        if (add.cid[i].checked)
          a.push(add.cid[i].value);
        //or
        //if (add.cid[i].checked)
         //   a.push(1);
        //else
        //   a.push(0);
      }
      
    return a.join('|');
    }then in selectb.jsp,  on server side, you can do a split
      

  3.   

    saucer(思归, MS .NET MVP):
    在接受端怎么做呢?我用JSP写的,用JSP的get.ParameterValuse[]数组来实现取得数据。
      

  4.   


    取得参数
     <script>
      var a = window.dialogArguments
      alert("您传递的参数为:" + a)
     </script>
      

  5.   

    function check(){
    var a = new Array();
    for(i=0;i<add.cid.length;i++)
    {
      if (add.cid[i].checked)
        a.push(add.cid[i].value);
    }
    return a;
    }showModalDialog("selectb.jsp", check(), "");
      

  6.   

    思归的意思大概是先把选择的个数和值存入一个动态字符串数组,并用“|”连接起来,然后在server端用split方法获取以“|”为标志符的每个参数
    关于split("标志符")[下标]的使用,可以在msdn搜索一下,有很多例子~~
      

  7.   

    因为我是用JSP写的SERVER端,下一个页面怎么写?
      

  8.   

    TO awaysrain(绝对零度)
    有没有具体的代码呢?
      

  9.   

    script>
    function check(){
    var a = new Array();
    var cidx="";
    for(i=0;i<add.cid.length;i++)
      {
        if (add.cid[i].checked)
          a.push("cid=" + add.cid[i].value);
        //or
        //if (add.cid[i].checked)
         //   a.push("cid=" + 1);
        //else
        //   a.push("cid=" + 0);
      }
      
    return a.join('&');
    }window.showModalDialog("selectb.jsp?cid="+check(),window,'scroll:0;status:0;help:0;resizable:0;dialogWidth:480px;dialogHeight:370px');
    string[] s = request.getParameterValues("cid");
      

  10.   

    sorrywindow.showModalDialog("selectb.jsp?"+check(),window,'scroll:0;status:0;help:0;resizable:0;dialogWidth:480px;dialogHeight:370px');
      

  11.   

    TO saucer(思归, MS .NET MVP)
    问题是在服务器端,也就是selectb.jsp中如何接受这一串参数,又如何把它分解出来呢?
    谢谢!!!
      

  12.   

    if you pass data like "selectb.jsp?cid=1&cid=2&cid=3", you can usestring[] s = request.getParameterValues("cid");
      

  13.   

    TO saucer(思归, MS .NET MVP):
    问题是,传入的值可能是不同类型,可能传入的是这样的:
    id=1
    cid=021
    cname=wto
    cpass=eb
      

  14.   

    that is totally different  Enumeration parameters = request.getParameterNames();
      String param = null;  while( parameters.hasMoreElements() )
      {
         param = (String)parameters.nextElement();
         String value = request.getParameter( param );
      }