我想做一个这样的页面: 项目:文本框 选择按钮 
点击选择按钮,弹出一个所有“项目”小窗口,可以单选,多选,选中后,确认,值在文本框读出。
如果是多选,表现形式为一个文本框对应一个项目
请问这个页面是怎么做的?谢谢!

解决方案 »

  1.   

    a.htm:
    <input type="text" id="txt"><div id="div" style="display:none"></div>
    <input type="button" value="选择" onClick="choose();">
    <script>
    function choose(){
      var value="";
      var result=[];
      value=window.showModalDialog("b.htm","width=400;height=300;");
      alert(value);
      result=value.split(/,/g);
      if(result.length>0){
    document.getElementById("txt").value=result[0];
        if(result.length>1){
    var str="";
    for(var i=1;i<result.length;i++){
    str=str+"<input type='text' value='"+result[i]+"'>";
    }
    document.getElementById("div").innerHTML=str;
    document.getElementById("div").style.display="";
    }
      }
    }
    </script>b.htm:
    <input type="checkbox" name="ch" value="项目1">项目1
    <input type="checkbox" name="ch" value="项目2">项目2
    <input type="checkbox" name="ch" value="项目3">项目3
    <input type="checkbox" name="ch" value="项目4">项目4
    <input type="button" value="确定" onClick="ok();">
    <script>
     function ok(){
    var obj=document.getElementsByName("ch");
    var value="";
    var n=0;
    for(var i=0;i<obj.length;i++){
    if(obj[i].checked){
    value=value+obj[i].value+",";
    n++;
    }
    }
    value=value.replace(/,$/g,""); window.returnValue=value;
    window.close();
     }
    </script>
      

  2.   

    是的,我的ie是6.0sp2,会不会和这个有关系?弹出的页面是空白的
      

  3.   

    to lip009(深蓝忧郁):出来了,很抱歉,我把a.htm,改成了a.html,所以就出来空白的