父页面有个按钮,点击后弹出个窗口,用户在子窗口选择后,点击“确定”后,关闭子窗口,同时,提交用户选择的内容给父窗口,在父窗口的一个控件上显示其选择的内容,可以实现吗?怎么实现啊?
(如果,我想传递的内容是标题+id号,可以吗?用户可以点击父窗口上的这个控件,又弹出另一个窗口,显示详细内容。)

解决方案 »

  1.   

    方法一:
    Main.htm<form name=myfrm>
    <input type=text Name=txtValue>
    <input type=button value=打开 onclick="openWin()">
    </form>
    <Script>
    function openWin()
    {
        window.open("ClientWin.htm","","width=200,height=200");
    }
    </Script>ClientWin.htm:<input type=text name=txtName>
    <input type=button value=确定 onclick="OK()">
    <Script>
    function OK()
    {
        opener.document.myfrm.txtValue.value=txtName.value;
        window.close();
    }
    </Script>
      

  2.   

    方法二
    Main.htm<form name=myfrm>
    <input type=text Name=txtValue>
    <input type=button value=打开 onclick="openDialog()">
    </form>
    <Script>
    function openDialog()
    {
        var rt=window.showModalDialog("Dialog.htm","","dialogwidth:200px;dialogheight:200px");
    }
    </Script>dialog.htm:<input type=text name=txtName>
    <input type=button value=确定 onclick="OK()">
    <Script>
    function OK()
    {
        window.returnValue=txtName.value;
        window.close();
    }
    </Script>
      

  3.   

    你自己改在ASPX中作回传向子窗口传参数都可在页面名后加:?参数名=值&参数名=值
    的方式传
      

  4.   

    用showModalDialog返回的值可不可以是多个吗?(title+id)
      

  5.   

    可以啊
    window.returnValue=title+":"+id;
    var rt=window.showModalDialog("Dialog.htm","","dialogwidth:200px;dialogheight:200px");
    try{
       array=rt.split(":");
       //array[0]就是title,array[1]就是id
    }
    catch{}
      

  6.   

    对,要不用ASP。NET ,要不用JAVASCRIPT都可以的