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

passing variables to a pop-up window not working

Contributor ,
Dec 03, 2009 Dec 03, 2009

Copy link to clipboard

Copied

Hello

:

I'm trying to pass records to a popup window and I can't get it to work properly. Can anyone help me figure out what I'm doing wrong? I'm stumped!

This is my code:

the link that spawns it and the java script used for the window:

<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
<!-- Begin
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
//  End -->
</script>

<a href="detail.cfm?ID=#ID#" onClick="NewWindow(this.href,'name','450','310','yes');return false;" class="dateNav">#place3#, #place2#</a>

here is the code for the query on the page in the pop up window:

<cfparam name="url.ID" type="integer" default="0">
<cfparam name="variables.ID" type="integer" default="#url.ID#">

<cflock timeout="2" scope="SESSION" type="READONLY">
<CFQUERY name="getBaby" datasource="#APPLICATION.dataSource#" cachedwithin="#CreateTimeSpan(0, 6, 0, 0)#">
SELECT nursery.MyImage AS place1, nursery.BFname AS place2, nursery.BLname AS place3, nursery.Blb AS place4, nursery.Bht AS place5, nursery.Date_Born AS place6, nursery.ID AS ID
FROM nursery
WHERE nursery.ID = <cfqueryparam value="#url.ID#" cfsqltype="cf_sql_integer">
</CFQUERY>
<cfset getBaby=getBaby>
</cflock>

I am obviously missing something here, but can't figure out what it is.

TOPICS
Advanced techniques

Views

1.1K

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
Valorous Hero ,
Dec 03, 2009 Dec 03, 2009

Copy link to clipboard

Copied

What exactly is failing?

Is the window not opening?

Is it not showing the proper cfm file?

Is it not passing in the desired URL value?

The only guess I can make, since I don't know if you are showing all your code or just parts of it.  Is there a <cfoutput>...</cfoutput> block around the anchor <a ...> tag?

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
Contributor ,
Dec 03, 2009 Dec 03, 2009

Copy link to clipboard

Copied

I have it surrounded by a query, I just gave you the bear bones. It has the id

in my link, but when the window opens, it doesn't bring up any records at all.

I didn't want to dump all this code on anyone. It's a lot going on in the main page where the <a> is. The main page works nice, I just can't get a record to show when you click on the link and try to pull up the full record in the pop up window. Is it the Java that's losing it?

this is the query tag:

<cfoutput query="memDB" startrow="#StartRow#" maxrows="#MaxRows#">

<a....> my link</a>

</cfoutput>

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
Valorous Hero ,
Dec 03, 2009 Dec 03, 2009

Copy link to clipboard

Copied

Then have you dumped the url scope on your pop page to insure that it is the value you expect it to be and that this value will return a record from your database?

Putting a <cfdump var="#url#"> at the top of the popup page is always a good place to start.

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
Contributor ,
Dec 03, 2009 Dec 03, 2009

Copy link to clipboard

Copied

Yes, I get this:

struct
ID21

That was my first move.

For some reason, maybe it isn't catching the query? I'm trying a couple ideas... no luck yet.

so the ID is getting to the page....... it also shows up in teh address bar in the pop up.

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
Valorous Hero ,
Dec 03, 2009 Dec 03, 2009

Copy link to clipboard

Copied

The next thing I would try is a dump of the query record set immediatly after the <cfquery...> tag.

As well as looking at the results returned, closely examin the SQL statement that was generated by ColdFusion and sent to the database.

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
Community Expert ,
Dec 07, 2009 Dec 07, 2009

Copy link to clipboard

Copied

I just gave you the bear bones.

Not the beef! How very dare you.

I didn't want to dump all this code on anyone.

We don't mind. Go on.

In the meantime, here are some suggestions to get your teeth into:

- Remove cachedwithin="#CreateTimeSpan(0, 6, 0, 0)#". Put it back only after your tests have succeeded. Otherwise, Coldfusion might serve old query results.

- You mention two queries, getBaby and memDB. What's the connection? While on the subject, what's the deal with <cfset getBaby=getBaby>?

- Remove the session lock. There is apparently no need for it.

- How do you know the query records aren't displayed? We see no display code. As Ian has suggested, put <cfdump var="#getBaby#"> right after the query.

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
LEGEND ,
Dec 03, 2009 Dec 03, 2009

Copy link to clipboard

Copied

This:

win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus();

doesn't appear to have any url varialbles.

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
Valorous Hero ,
Dec 03, 2009 Dec 03, 2009

Copy link to clipboard

Copied

The myPage variable is apparently populated from this.href in the function call inside the anchor tag onClick event.  So, it should, I think.

And an earlier post said that a dump of the url scope showed it populated with the expected 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
Community Beginner ,
Dec 06, 2009 Dec 06, 2009

Copy link to clipboard

Copied

How about using Val(ID) instead of cfqueryparam?

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
Community Beginner ,
Dec 07, 2009 Dec 07, 2009

Copy link to clipboard

Copied

I bet, cfqueryparam can't be used within  cachedwithin of cfquery.

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
Community Expert ,
Dec 07, 2009 Dec 07, 2009

Copy link to clipboard

Copied

LATEST

@Pyae Phyoe Shein

I bet, cfqueryparam can't be used within  cachedwithin of cfquery.

You're right. That. too.

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