长毛 发表于 2006 年 11 月 14 日 10:14:49

showModalDialog 回传值问题?

AA.htm
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>主界面</title>
</head>

<body>
<script language="JavaScript">   
function openWin1()   
{      
var srcFile = "BB.htm";    //新窗口的文档名称      
var winFeatures = "dialogWidth:180px;dialogHeight:100px;help:no;scroll:no;status:no;toolbar:no;menubar:no;scrollbars:no;location:no;resizable:no;";      
var obj = lt_form;//将form作为对象传递给新窗口               
window.showModalDialog(srcFile, obj, winFeatures);
if(obj!=undefined){
document.write(obj);
}
}

</script>
<form id="lt_form">   
回传值:
<input type="text" id="num1" readOnly>
<input type="text" id="num2" readOnly>
<input type="text" id="num3" readOnly>
</form>
<input type="button" value="打开新窗口1" onClick="openWin1()">
[<A style="CURSOR: hand" onClick="openWin1()">新窗口</A>]
</body>

</html>

AA.htm要得到BB.htm的连续回传值,请问如何实现,
我用下面的要加起连续回传值不行...
if(obj!=undefined){
document.all.allgold.innerHTML = eval(document.all.allgold.innerHTML+"+"+obj);
}

BB.htm

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新窗口BB</title>
<style type="text/css">
<!--
body {
      margin-left: 0px;
      margin-top: 0px;
      margin-right: 0px;
      margin-bottom: 0px;
      background-color: #D78413;
}
.style2 {font-size: 12px}
-->
</style>
</head>
<base target="_self">
<body>
<form id="lt_form"><span class="style2">请输入金额:</span>
<input type="text" id="money" onKeyDown="if(window.event.keyCode==13)send(lt_form.money.value),form.reset();" style="border-style:solid;border-width:1;padding-left:4;padding-right:4;padding-top:1;padding-bottom:1" onMouseOver="this.style.background='#E1F4EE';" onMouseOut="this.style.background='#FFFFFF'" size="8">
<br>               
<input type="reset" name="button" value="关闭" onClick="window.close();">
</form>
<script language="JavaScript">   
function send(val,val1)   
{   
if(document.getElementById("money").value.length==0){
alert("请输入金额!");
} else if(isNaN(document.getElementById("money").value)){
alert("请输入数字!");
} else {
    //取得父窗口传过来的对象      
    var myObj = window.dialogArguments;      
    //赋值
      var   s, ss, get,num, strAll;
      var   s = val;
      var ss = s.substr(0, 2);   //   获取子字符串。
      var val1 = s.substr(2, 8);   //   获取子字符串。
    var get = "getData";
      var getData = get + ss;
      if (ss=="01"){
    myObj.num1.value = val1;
      }
      if (ss=="02"){
      myObj.num2.value = val1;
      }
      if (ss=="03"){
      myObj.num3.value = document.getElementById("money").value;
      }
    //关闭窗口
      }
}

</script>

</body>

</html>
页: [1]
查看完整版本: showModalDialog 回传值问题?