在一个网页里有
一个text框旁边有个button按钮
当点击button按钮,一个层显示出来。
上面有两个按钮,一个是确定按钮。一个是清空按钮
按钮下面是从数据库里得到的数据,前面带有每行数据前面都带有复选框。
对于复选框最多只可以选择20个,如果超过20个,则提示。
当点击确定按钮后。text框里会出现a,b
比如:
选择北京、上海、天津。则text框里出现
北京,上海,天津
如何做谢谢大家。

解决方案 »

  1.   

    简单说一个解决方案:
    1.点击button按钮触发js事件,调用模式对话框
    var p = window.showModalDialog("iframe.html", , "dialogHeight:300px; dialogLeft:200px;");
    2.第二个页面中是一个仅包含iframe的空白页iframe.html
    <iFRAME SRC="modalDialogSource.htm" NAME="" width="100%" height="100%"/>
    原因是模式对话框返回值需要
    3.在第三个页modalDialogSource.htm中查库我就不说了,只说点击确定按钮调用的js
    var zhi= document.getElementById("id").value
    returnValue = zhi;
    4.在起始页js中即window.showModalDialog 的下面就可以收到zhi了,但此时是p
      

  2.   

    <html>
    <head>
    <script>
    function showdiv(){
    document.getElementById('div').style.display='block';
    }function onclick1(){
    var cks = document.form1.chk;
    var count = 0;
    var s = "";
    for(var i=0;i<cks.length;i++){
    if(cks[i].checked){
    count++;
    s +=cks[i].value;
    }
    }if(count>3){
    alert('不能超过3个');
    return;
    }
    document.getElementById('text').value = s;}function onclick2(){
    var cks = document.form1.chk;
    for(var i=0;i<cks.length;i++){
    if(cks[i].checked){
    cks[i].checked = false;
    }
    }
    }
    </script>
    </head>
    <body>
    <form name='form1'>
    <input id='text'/><input type='button' onclick='showdiv()'/><br>
    <div style='display:none' id='div'>
    <input type='button' value='确定' onclick='onclick1()'/><input type='button' value='清空'onclick='onclick2()'/><br>
    1<input type ='checkbox' name='chk' value=1 />
    2<input type ='checkbox' name='chk' value=2 />
    3<input type ='checkbox' name='chk' value=3 />
    4<input type ='checkbox' name='chk' value=4 />
    5<input type ='checkbox' name='chk' value=5 />
    </div>
    </form>
    </body>
    </html>简单的写了下,取数据库就自己去弄吧