Pass query string using popup

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TErnst

    #1

    Pass query string using popup

    Hello All....

    What I am attempting to do is have a link/button on a page
    (testpopup.cfm) that opens a popup page (popupwindow.cf m). The popup
    page displays a resultset from a query and the selected record needs
    to be passed through a query string/URL parameter to the original
    calling page and will be available in the body onload event of the
    calling page.

    I open the popup window and display the query results, I then click on
    a record and the record is then displayed in the calling form textbox
    (txtOrg) - - - only the calling form appears in the POPUP window!
    This is not what I need it to do. I need it to pass the URL parameter
    to the calling page and close the popup. Here is the code from the
    two pages. Can you shed any light on this?


    testpopup.cfm

    <html>
    <head>

    <script language="JavaS cript">
    var strValue = location.search .split( '=' )[1];
    </script>
    </head>

    <body onLoad="documen t.MyForm.txtOrg .value = strValue;">

    <form action="" method="get" name="MyForm" id="MyForm">
    <input name="txtOrg" type="text" id="txtOrg">
    <input type="button" name="choice"
    onClick="window .open('popupwin dow.cfm','','wi dth=300,height= 300,top=100,lef t=100');"
    value="Search for Org"><br>
    </form>

    </body>
    </html>

    popupwindow.cfm

    <html>
    <head>

    <cfquery name="OrgDetail " datasource="InT ouch">
    select * from vwOrgDetail
    </cfquery>

    <title>Select Organization</title>
    </head>
    <body>

    <cfoutput query="OrgDetai l">
    <a href="testpopup .cfm?Name=#Name #"
    onclick="javasc ript:self.close ()">#Name#</a><br>
    </cfoutput>

    </body>
    </html>
  • kaeli

    #2
    Re: Pass query string using popup

    In article <f0cc45bb.04102 60958.27f1ae66@ posting.google. com>,
    taraernst@new.r r.com enlightened us with...[color=blue]
    >
    > I open the popup window and display the query results, I then click on
    > a record and the record is then displayed in the calling form textbox
    > (txtOrg) - - - only the calling form appears in the POPUP window!
    > This is not what I need it to do. I need it to pass the URL parameter
    > to the calling page and close the popup. Here is the code from the
    > two pages. Can you shed any light on this?[/color]

    Yeah, you're targeting the same window. Why would it open in the other one?
    ;)
    [color=blue]
    >
    > <cfoutput query="OrgDetai l">
    > <a href="testpopup .cfm?Name=#Name #"
    > onclick="javasc ript:self.close ()">#Name#</a><br>[/color]

    Right there. No target. Hence, target is self.

    <a href="testpopup .cfm?Name=#name #" target="window. opener"
    onClick="self.c lose()">

    Ditch the "javascript " from event handler onClick: it's redundant. All
    handlers are javascript unless specified otherwise (vbscript for IE).

    Also, you may have a problem doing the self.close in the onClick, since I'm
    not sure that it won't close the window BEFORE the anchor is followed (thus,
    the main page would do nothing).

    This might work a lot better:
    (note quotes changed to avoid nesting issues)

    <a href="#" onClick='doIt(" #Name#"); return false;'>link</a>

    function doIt(name)
    {
    window.opener.h ref="testpopup. cfm?Name="+name ;
    self.close();
    }

    Give it a shot.
    HTH
    --
    --
    ~kaeli~
    A midget fortune teller who escapes from prison is a small
    medium at large.



    Comment

    Working...