js实现父页面接收子页面传的值

一:父页面

1:校对人员编号文本框代码:

<input name="txtJDRY" type="text" id="txtJDRY" size="10" maxlength="40" readonly="readonly" value="${requestScope.txtGetYhbh }" class="ReadonlyText"/>

2:查找编号按钮代码:

<input type="button" name="Button2" value="查找编号" onClick="SearchCode()" accesskey="Q" style="cursor='hand'"/>

3:查找编号按钮所调用的js方法:SearchCode(),当点击查找编号按钮之后弹出如下图片:

function SearchCode(){
	    var wndMEPImgPreView=window.open("<%=basePath%>cxaction.do?action=cxJDRY","wndMEPImgPreView","toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=600,left=200,top=200");
		wndMEPImgPreView.focus();
	}


二:子页面

单选框代码:

<c:forEach items="${listUsers}" var="message" varStatus="index">
	  				<tr onMouseOver="this.style.background='#ececec'" onMouseOut="this.style.background='#ffffff'" style="cursor='hand'">
	  				
	  				
	  					<td align="center"><input type="radio" id="txtGetYhbh" name="txtGetYhbh" value="${message.yhbh}" /></td>
	  					
	  					
	  					<td align="center">${message.yhbh}</td>
	  					<td align="center">${message.yhmc}</td>
	  					<td align="center">${message.zsxm}</td>
	  				</tr>
	  			</c:forEach>



1:选中其中的一个单选按钮,点击添加编号按钮会将选中的用户编号传到父页面

其中这个页面的js代码如下:

button按钮:

<input name="btnquery" type="button" id="btnquery" value="   添加编号   " style="cursor='hand'" οnclick="win()">
js win()方法:

function win(){
	   var radios = document.getElementsByTagName("input");
		for(var i = 0 ;i<radios.length ; i++){
			if(radios[i].type=="radio"   && radios[i].checked){
				window.opener.document.getElementById("txtJDRY").value=radios[i].value;//txtJDRY是要显示在父页面中那个文本框里的文本框的id
			}
		}
	   window.close();
	}
2:当点击添加编号按钮之后,会将你选中的单选框中的用户编号传入父页面的文本框中 例如:选中编号为21,图如下:


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值