利用Js来进行值传递

利用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();   
    }   

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值