我将文本字段值从父cfm页面传递到我在点击按钮或链接后打开的子窗口。
<form name="parentForm" action="">
<input type="text" id="parentValue" value="" />
<input type="button" value="Open Popup" onclick ="javascript:LaunchPopup('openP.cfm');"/>
</form>
<script type="text/javascript">
function LaunchPopup(page) {
OpenWin = window.open(page, "myWindow", "width=400,height=200");
}
</script>
<!--- Child page : openp.cfm --->
<script>
if (opener.document){
mother = opener.document;
document.form1.popupValue.value = mother.parentForm.parentValue.value;
}
</script>
<form id="form1">
Value from the calling page: <input type="text" id="popupValue" value="" />
</form>
但由于某种原因,我无法传递我在父页面中输入的值。点击按钮后,我想看到我在父页面输入的值。
答案 0 :(得分:3)
父页
<input
type="button" value="Open Popup"
onclick ="javascript:LaunchPopup('openP.cfm?parent=' + document.parentForm.parentValue.value);"
/>
<强> openp.cfm 强>
<cfparam name="url.parent" default="">
<form id="form1">
Value from the calling page:
<input type="text" id="popupValue" value="<cfoutput>#url.parent#</cfoutput>" />
</form>