• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Passing Dynamic Loop Data From Child Page To Parent

New Here ,
Jan 20, 2010 Jan 20, 2010

Copy link to clipboard

Copied

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...')">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>

TOPICS
Advanced techniques

Views

495

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 20, 2010 Jan 20, 2010

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)">

Votes

Translate

Translate
LEGEND ,
Jan 20, 2010 Jan 20, 2010

Copy link to clipboard

Copied

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)">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 20, 2010 Jan 20, 2010

Copy link to clipboard

Copied

LATEST

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#)">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation