日期:2014-05-18  浏览次数:20374 次

弹出窗口返回值到父窗口的两个文本框?
子窗口返回值到父窗口的一个文本框用下面的方法:
//父窗口弹出方法        
  function   openbm()
          {
              var   returnValue=window.showModalDialog( 'bumen_father.aspx ', ' ', 'dialogHeight:352px;dialogWidth:566px;center:yes;help:no;status:no;scroll:yes ');
           
             
              document.form1.Text1.value=returnValue;
          }    

//子窗口关闭事件
  <script   type= "text/javascript ">
                          function   closewin()
            {
   
                      var   n   =store.document.getElementById( 'ListBox1 ').selectedIndex;
                      if   (n== '-1 ')  
                      {              
                alert( '请右边框选择用户! ');
                return   false;
                }else
                {    

                                  document.form1.Hidden1.value=store.document.getElementById( 'ListBox1 ').options[n].text+ ', '+store.document.getElementById( 'ListBox1 ').options[n].value;     //获取左框架的值  
                         

                                  window.returnValue=document.form1.Hidden1.value;
                                  window.close();
                        }
            }
            function   canForm()
            {
                    window.returnValue= ' ';
                    window.close(this);
            }
           
        </script>
但如果父窗口有两个文本框(如text1返回用户,text2返回id)又该如何?

------解决方案--------------------
但如果父窗口有两个文本框(如text1返回用户,text2返回id)又该如何?
--------------------------------
方法比较多

1.
使用数组返回
// child.htm
window.returnValue = [myUserName, myUserId];
/* also
var arr = new Array();
arr[arr.length] = myUserName;
arr[arr.length] = myUserId;
window.returnValue = arr;
*/

// parent.htm
var retVal = window.showModalDialog(........
alert(retVal[0]);
al