Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    JME
    JME is offline
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cannot successfully pass data from popup to parent

    I have followed directions from other websites on how to code to successfully pass data from a popup to a parent page but I cannot get the data to display on the parent page. Hoping someone can give me the missing link.

    Here are my code snippets (BTW I am working with coldfusion but the passing code is javascript):

    Parent page:


    <cfform id="frmRelease" name="frmRelease" method="post" preservedata="yes" action="preview.cfm?action=edit" enctype="multipart/form-data" onsubmit="return submitForm();">

    //hidden field that should hold the passed data. I have debug code that should show me the passed data once the page reloads but I never get the passed data displayed.

    <input type="hidden" name="contactListing" />
    <cfif isDefined("form.contactListing")><cfoutput> this is contact list #form.contactListing#</cfoutput><cfelse><cfoutput>there is no contact list </cfoutput></cfif>


    <script language="JavaScript 1.2" type="text/javascript">
    <!--
    function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=500,left = 190,top = 62');");
    }

    </script>


    //where I call the popup
    <legend>Contact &nbsp;&nbsp; <a href="javascript:popUp('contactList.cfm?id=<cfoutput>#releaseID#</cfoutput>&page=edit')">Select Contacts</a></legend>

    Popup page:
    //The page displays a number of selections for the user. I then collect the data on submit and create a variable to pass the data back to the parent. I have debug alerts that show me I do have data before I transfer and that I supposedly successfully transfer the data.

    <cfform id="frmContact" name="frmContact" method="post" preservedata="yes" onsubmit="submitForm();window.close();">
    <input type="hidden" name="contactList" />
    <script language="javascript">
    function submitForm()
    {
    alert("i am here");
    var numContacts = document.frmContact.numberOfContacts.value;
    for(i=1;i<=numContacts;i++){
    if(eval('document.frmContact.order' + i + '.value')!=''){
    if(isNaN(eval('document.frmContact.order' + i + '.value'))){
    eval('document.frmContact.order' + i + '.select()');
    alert('Please enter a proper value in the order box');
    return false;
    }
    }
    }
    var contactArray=new Array();
    var contactCounter = 0;
    var passBackContacts = "";
    for (i=1;i<=document.frmContact.numberOfContacts.value; i++){
    if (passBackContacts != ""){
    passBackContacts = passBackContacts + "," ;
    }
    if(eval('document.frmContact.order' + i + '.value')!=''){
    contactCounter = contactCounter++;
    contactArray[contactCounter] = eval('document.frmContact.order' + i + '.value')+","+eval('document.frmContact.contactID' + i + '.value');
    passBackContacts=passBackContacts + eval('document.frmContact.order' + i + '.value');
    }
    else {
    passBackContacts=passBackContacts+"0";
    }
    }
    alert("test that we have data passbackcontacts = "+passBackContacts);
    window.opener.document.frmRelease.contactListing.value =passBackContacts;
    alert("after assignment");
    opener.location.reload();
    }
    </script>

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    it doesn't matter what server-side language you are using. just post the generated html
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #3
    JME
    JME is offline
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    generated HTML for parent - stripped to include only pertinent info

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <html lang="en-us">
    <head>
    <script language="JavaScript" type="text/javascript" src="html2xhtml.js"></script>
    <script language="JavaScript" type="text/javascript" src="richtext_compressed.js"></script>


    <script LANGUAGE=JAVASCRIPT TYPE="text/javascript" >

    <!--

    function _CF_checkfrmRelease(_CF_this)

    {

    return submitForm();

    return true;

    }


    //-->

    </script>

    </head>

    <body>


    <FORM NAME="frmRelease" ACTION="preview.cfm?action=edit" METHOD=POST onSubmit="return _CF_checkfrmRelease(this)" ENCTYPE="multipart/form-data" ID="frmRelease">

    <input type="hidden" name="releaseID" value="28" /> this is releaseid 28

    <input type="hidden" name="contactListing" />
    there is no contact list


    <script language="JavaScript 1.2" type="text/javascript">
    <!--
    function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=500,left = 190,top = 62');");
    }



    </script>


    <legend>Contact &nbsp;&nbsp; <a href="javascriptopUp('contactList.cfm?id=28&page=edit')">Select Contacts</a></legend>

    </FORM>







    </body>
    </html>














    generated HTML for Popup - stripped to include only pertinent info

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <html lang="en-us">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <script language="javascript">
    function submitForm()
    {
    var numContacts = document.frmContact.numberOfContacts.value;
    for(i=1;i<=numContacts;i++){
    if(eval('document.frmContact.order' + i + '.value')!=''){
    if(isNaN(eval('document.frmContact.order' + i + '.value'))){
    eval('document.frmContact.order' + i + '.select()');
    alert('Please enter a proper value in the order box');
    return false;
    }
    }
    }
    var contactArray=new Array();
    var contactCounter = 0;
    var passBackContacts = "";
    for (i=1;i<=document.frmContact.numberOfContacts.value; i++){
    if (passBackContacts != ""){
    passBackContacts = passBackContacts + "," ;
    }
    if(eval('document.frmContact.order' + i + '.value')!=''){
    contactCounter = contactCounter++;
    contactArray[contactCounter] = eval('document.frmContact.order' + i + '.value')+","+eval('document.frmContact.contactID' + i + '.value');
    passBackContacts=passBackContacts + eval('document.frmContact.order' + i + '.value');
    }
    else {
    passBackContacts=passBackContacts+"0";
    }
    }
    alert("test that we have data passbackcontacts = "+passBackContacts);
    window.opener.document.frmRelease.contactListing.value =passBackContacts;
    alert("after assignment");
    opener.location.reload();
    }
    </script>



    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>


    <script LANGUAGE=JAVASCRIPT TYPE="text/javascript" >

    <!--

    function _CF_checkfrmContact(_CF_this)

    {

    submitForm();window.close();

    return true;

    }


    //-->

    </script>

    </head>

    <body>
    <FORM NAME="frmContact" METHOD=POST onSubmit="return _CF_checkfrmContact(this)" ID="frmContact">

    <table>
    <tr>
    <th align="center">Contact</th>
    <th align="center">Order</th>
    </tr>

    <input type="hidden" name="contactID1" value="1"/>
    <tr>
    <td><label for="order1" class="shortLabel">&nbsp;&nbsp;Kevin&nbsp;Hall</label></td>
    <td><input type="text" size="1" name="order1" /></td>
    </tr>

    <input type="hidden" name="contactID2" value="6"/>
    <tr>
    <td><label for="order2" class="shortLabel">&nbsp;&nbsp;Delacey&nbsp;Skinner</label></td>
    <td><input type="text" size="1" name="order2" /></td>
    </tr>

    <input type="hidden" name="contactID3" value="7"/>
    <tr>
    <td><label for="order3" class="shortLabel">&nbsp;&nbsp;Charles&nbsp;Pyle</label></td>
    <td><input type="text" size="1" name="order3" /></td>
    </tr>

    <input type="hidden" name="contactID4" value="8"/>
    <tr>
    <td><label for="order4" class="shortLabel">&nbsp;&nbsp;Kathy&nbsp;Glazer</label></td>
    <td><input type="text" size="1" name="order4" /></td>
    </tr>

    <input type="hidden" name="contactID5" value="9"/>
    <tr>
    <td><label for="order5" class="shortLabel">&nbsp;&nbsp;Shea&nbsp;Hollifield</label></td>
    <td><input type="text" size="1" name="order5" /></td>
    </tr>

    <input type="hidden" name="contactID6" value="10"/>
    <tr>
    <td><label for="order6" class="shortLabel">&nbsp;&nbsp;Kelly&nbsp;Lobanov</label></td>
    <td><input type="text" size="1" name="order6" /></td>
    </tr>

    <input type="hidden" name="contactID7" value="11"/>
    <tr>
    <td><label for="order7" class="shortLabel">&nbsp;&nbsp;Christie&nbsp;Collins</label></td>
    <td><input type="text" size="1" name="order7" /></td>
    </tr>

    <input type="hidden" name="contactID8" value="12"/>
    <tr>
    <td><label for="order8" class="shortLabel">&nbsp;&nbsp;Jeff&nbsp;Kraus</label></td>
    <td><input type="text" size="1" name="order8" /></td>
    </tr>

    <input type="hidden" name="contactID9" value="13"/>
    <tr>
    <td><label for="order9" class="shortLabel">&nbsp;&nbsp;Bob&nbsp;Spieldenner</label></td>
    <td><input type="text" size="1" name="order9" /></td>
    </tr>

    <input type="hidden" name="numberOfContacts" value="9">


    </body>
    <p><input type="submit" name="submit" value="Accept Changes">&nbsp; &nbsp;<input type="submit" value="Cancel" name="btnCancel" onClick="javascript:window.close();">
    </p>
    </FORM>
    </html>

  • #4
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    I see that the data is being passed correctly.

    Try to change highlighted to text (temporarily) to see the value:
    Code:
    <input type="hidden" name="contactListing" />
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #5
    JME
    JME is offline
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Found that it is a problem with the reload - what I want to be able to do is use the data passed to create a results display on the parent page. To do that I was looking to reload the page, utilize the data to get info from a database and then display the results on the parent page. But it appears that the reload is not able to read the value of the hidden field and/or does not retain the value for redisplay.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •