Pass query string using popup

T

TErnst

Hello All....

What I am attempting to do is have a link/button on a page
(testpopup.cfm) that opens a popup page (popupwindow.cfm). 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="JavaScript">
var strValue = location.search.split( '=' )[1];
</script>
</head>

<body onLoad="document.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('popupwindow.cfm','','width=300,height=300,top=100,left=100');"
value="Search for Org"><br>
</form>

</body>
</html>

popupwindow.cfm

<html>
<head>

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

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

<cfoutput query="OrgDetail">
<a href="testpopup.cfm?Name=#Name#"
onclick="javascript:self.close()">#Name#</a><br>
</cfoutput>

</body>
</html>
 
K

kaeli

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?

Yeah, you're targeting the same window. Why would it open in the other one?
;)
<cfoutput query="OrgDetail">
<a href="testpopup.cfm?Name=#Name#"
onclick="javascript:self.close()">#Name#</a><br>

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

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

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.href="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.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top