将文本框值从父页面传递到cfm中的子窗口

时间:2016-06-04 10:44:39

标签: javascript jquery coldfusion

我将文本字段值从父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>

但由于某种原因,我无法传递我在父页面中输入的值。点击按钮后,我想看到我在父页面输入的值。

1 个答案:

答案 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>