利用Js来进行值传递:看下面脚本
以下在页面上写脚本(父窗体)
<script>
//补充完成下边的函数,打开新的一个模式窗口
function openShowModalDialog(){
var a = window.showModalDialog("DEMO04_01.html","这是新打开的一个窗体")//直接得到返回值
document.getElementById('showContentDiv').innerHTML+=a;
}
</script>
<body>
<button οnclick="openShowModalDialog();">打开新的模式窗口</button>
<hr>
<div id="showContentDiv">
</div>
</body>
/*------------------------------------------*/
以下为子窗体中脚本
<script>
//补充完成函数,将文本框returnValue的值设置为父窗口返回值,并关闭本窗口
function closeShowModalDialog(){
var p = document.getElementById('returnValue').value;
window.returnValue=p;//设置返回值,但是父窗体必须是window.showModalDialog接收
window.close();//关闭
}
</script>
<body>
<button οnclick="closeShowModalDialog();">设置返回值,并关闭窗口</button>
<hr>
窗口的返回值
<input type="text" id="returnValue" value="在这里设置返回值">
</body>
——————————————————————————————————————————————
父窗体:
function GetData()
{
var theForm = document.forms[0];
var StrTxts = ShowModeWinR("供应商维护"," OtherMan.aspx "," 965 "," 735 ");
theForm.TxtLinkMan.value = StrTxts[0];
theForm.TxtAddress.value = StrTxts[1];
theForm.TxtTel.value = StrTxts[2];
theForm.TxtFax.value = StrTxts[3];
}
function ShowModeWinR(sTitle,sFileName,w,h)
{
var sURL = "black.aspx?FileName=" + sFileName +"&Title=" + sTitle;
var nDialogWidth = w
var nDialogHeight = h;
var nLeft = (window.screen.availWidth-nDialogWidth)/2;
var nTop = (window.screen.availHeight-nDialogHeight)/2;
var sFeatures= "dialogLeft:"+nLeft+"px;dialogTop:"+nTop+"px;dialogHeight:"+nDialogHeight+"px;dialogWidth:"+nDialogWidth+"px;help:no;status:no";
var sReturnVal = window.showModalDialog(sURL,window,sFeatures) ;
return sReturnVal
}
模态窗体:
function sendTo()
{
var theForm = document.forms[0];
var StrLinkMan = theForm.TxtLinkMan.value;
var StrAddress = theForm.TxtAddress.value;
var StrTel = theForm.TxtTel.value;
var StrFax = theForm.TxtFax.value;
var a=new Array(StrLinkMan,StrAddress,StrTel,StrFax);
window.returnValue = a;
window.close();
}