在窗口中,用javascript打开模态窗口,在模态窗口中点击按钮,给父窗口的控件赋值(一共有6个个控件),用js怎么写啊?

解决方案 »

  1.   

    http://blog.csdn.net/tianzhenjing/archive/2006/11/22/1405435.aspx
      

  2.   

    parent.document.all["TextBox1"].value="abc";
      

  3.   

    To:tianzhenjing(宁静夏天)
    我看了这个网址的资料,参照上面的说明写了代码,但是发现一个奇怪的问题,当模态窗口关闭的时候,赋给父窗体TextBox中的值都被清空了,不知道怎么回事...
    代码如下:打开窗体:
     window.showModalDialog("ModuleCategorySelect.aspx",window,"dialogWidth:550px;dialogHeight:580px;status:no;directories:yes;scrollbars:no;Resizable=no;");模态窗口给父窗体赋值:
     var id1 = window.document.getElementById("hidCategory1").value;
        var text1 = window.document.getElementById("txtCategory1").value;     
        if(id1!= "" && text1!="")
        {
            window.dialogArguments.document.getElementById("hidCategory1").value=id1;
            window.dialogArguments.document.getElementById("txtCategory1").value=text1;              }
        
        var id2 = window.document.getElementById("hidCategory2").value;
        var text2 = window.document.getElementById("txtCategory2").value;
        if(id2!="" && text2!="")
        {
            window.dialogArguments.document.getElementById("hidCategory2").value=id2;               
        window.dialogArguments.document.getElementById("txtCategory2").value=text2;
    }

    var id3 = window.document.getElementById("hidCategory3").value;
    var text3 = window.document.getElementById("txtCategory3").value;
    if(id3!="" && text3!="")
    {
            window.dialogArguments.document.getElementById("hidCategory3").value=id3;
        window.dialogArguments.document.getElementById("txtCategory3").value=text3;
    }
    window.close();