macromedia.coldfusion.cfml_general_discussion
[Top] [All Lists]

Re: Passing back data from a popup window

Subject: Re: Passing back data from a popup window
From: "cf_dev2"
Date: Wed, 8 Aug 2007 17:52:30 +0000 UTC
Newsgroups: macromedia.coldfusion.cfml_general_discussion
Another option is to create a function in the main page that sets the value. 
Then call the function from the popup window instead of referencing the form 
field directly.  So if you ever change the form/fields in the main page it 
won't break the popup page. 



 <!--- main window form --->
 <script type="text/javascript">
        function openPopup() {
                //... open window
        }
        function fillName(text) {
                var elem = document.getElementById('employeeName');
                elem.value = text;
        }
 </script>
 <cfform>
        <cfinput type="text" id="employeeName" name="employeeName">
        <input type="button" value="Open Popup" onClick="openPopup()">
 </cfform>

 <!--- popup window --->
 <script type="text/javascript">
        function finish() {
                if (opener && opener.fillName) {
                        var elem = document.getElementById('newName');
                        opener.fillName(elem.value);
                }
                window.close();
        }
 </script>
 <form>
        <input type="text" id="newName" name="newName">
        <input type="button" value="Finish" onClick="finish();">
 </form>


<Prev in Thread] Current Thread [Next in Thread>