2 Replies Latest reply on Jan 20, 2010 7:32 PM by BrianTech3

    Passing Dynamic Loop Data From Child Page To Parent

    BrianTech3

      Hi All,

       

           I'm trying to create something where when a user clicks a link on the main page, javascript opens a new window which querys a database and displays the results.  The user then selects the result they want via a form button or url (doesn't matter which) from the child page, which sends a value to fill in a form field on the parent page.  Sounds simple, but I can't figure out how to get the information back to the parent page from the dynamic form in the child.  I get a value of Undefined in the form field on the parent page.  I think its because I'm using the same name for each button with a different value, and javascript doesn't like that.  I'm not really that good with JS, which I suspect is why I can't get it.  I'll post my code below, and any help is greatly appreciated.  Thank you!

       

      Parent Page:

       

      <cfform name="RRForm" action="Blah.cfm" method="POST">
      <table>
          <tr>
              <th align="right">Start Date:</th>
              <td><cfinput type="text" name="StartDate" value="#sdate#" validate="date" message="Please enter a valid START DATE" maxlength="10" size="10"></td>
          </tr>
          <tr>
              <td><br></td>
          </tr>
          <tr>
              <th align="right">End Date:</th>
              <td><cfinput type="text" name="EndDate" value="#edate#" validate="date" message="Please enter a valid END DATE" maxlength="10" size="10"></td>
          </tr>
          <tr>
              <td><br></td>
          </tr>
          <tr>
              <th align="right">Client Number(s):</th>
              <td><input type="text" name="clientnums" size="20" maxlength="60" value=""> <font style="font-size:8pt">(Comma Separated)</font>   <a href="javascript:void(0);" OnClick="window.open('http://192.168.0.189/BlahList.cfm','ClientList','toolbar=0,menubar=0,resizable=0,location= 0,status=0,scrollbars=1,height=300,width=500')">Client List</a></td>
          </tr>
          <tr>
              <td><br></td>
          </tr>
          <tr>
              <th align="right" valign="top">Precision Level:</th>
              <td><cfinput type="Radio" name="PrecisionLevel" value="Y" checked="No">Years<br><cfinput type="Radio" name="PrecisionLevel" value="M" checked="Yes">Months<br><cfinput type="Radio" name="PrecisionLevel" value="W" checked="No">Weeks<br><cfinput type="Radio" name="PrecisionLevel" value="D" checked="No">Days</td>
          </tr>
          <tr>
              <td><br></td>
          </tr>
          <tr>
              <th align="right">Display Zero:</th>
              <td><cfinput type="Checkbox" name="DisplayZero" value="1" checked="Yes"></td>
          </tr>
      </table>
      <br>
      <br>
      <input type="submit" name="RunReport" value="Run Report">
      </cfform>

       

       

       

      Child Page:

       

      <cfquery name="GetClients" datasource="BlahOLE">
          SELECT clientno,name,inactive
          FROM clients
          ORDER BY #sortcrit# ASC
      </cfquery>

       

      <html>
      <head>
          <script type="text/javascript">
            function SendInfo(){
              opener.document.RRForm.clientnums.value = document.CForm.PassData.value;
              window.close();
            }
          </script>

          <title>Client List</title>
          <style>
          td{font-size:10pt;}
          </style>
      </head>

       

      <body bgcolor="black" text="white" link="aqua" alink="red" vlink="aqua">
      <cfoutput>

       

      <form name="CForm" method="post">
      <table>
          <tr>
              <th><a href="http://192.168.0.189/BlahList.cfm?sortby=CNO">Client ##<hr></a></th>
              <th>   </th>
              <th><a href="http://192.168.0.189/BlahList.cfm?sortby=CNAME">Client Name<hr></a></th>
              <th>   </th>
              <th>Status<hr></th>
          </tr>
          <cfloop query="GetClients">
          <cfset cno=Trim(ClientNo)>
          <tr>
              <td><input type="Button" name="PassData" value="#cno#" style="width:50" onclick="SendInfo()"></td>
              <td></td>
              <td>#name#</td>
              <td></td>
              <td><cfif inactive is "FALSE"><font color="##33ff33">ACTIVE</font><cfelse><font colore="Silver">INACTIVE</font></cfif></td>
          </tr>
          <tr>
              <td colspan="5"><hr></td>
          </tr>
          </cfloop>

      </table>
      </form>
      </cfoutput>
      </body>
      </html>

        • 1. Re: Passing Dynamic Loop Data From Child Page To Parent
          Dan Bracuk Level 5

          You've diagnosed the problem correctly.  On your child page, all the textbox form fields have the same name.

           

          My approach would be for the SendInfo function on the child page to accept a value.  So

          function SendInfo()

          becomes

          function SendInfo(incomingValue)

           

          And you would call it like this:

           

          <input type="Button" name="PassData" value="#cno#" style="width:50" onclick="SendInfo(this.value)">

          • 2. Re: Passing Dynamic Loop Data From Child Page To Parent
            BrianTech3 Level 1

            Dan, that was exactly it.  Thank you so much for the help!   I'm displaying the corrected code changes below for future reference by others.

             

             

            <script type="text/javascript">
                  function SendInfo(incomingValue){
                  opener.document.RRForm.clientnums.value = incomingValue;
                  window.close();
                  }
            </script>

             

             

            AND

             

             

            <input type="Button" name="PassData" value="#cno#" style="width:50" onclick="SendInfo(#cno#)">