Solved

Cfwindow not working in a query output

Posted on 2013-01-18
19
718 Views
Last Modified: 2013-01-26
I would like to have a query output of a database, then have a cffileupload window pop up, base on the person they select. I can get the first window to pop up from the query but when I select the next one it has the same information as the first. I can only get one pop up to work right. What am I doing wrong, here is my code?


<cfoutput query="ordersku">

<cfajaximport tags="cfwindow,cffileupload,cfform"  >
   
<cfform name="test">



  <cfinput name="imageField" type="submit" value="#order_id#" class="member_button"  
        onMouseDown="ColdFusion.Window.create
        ('Window#order_id#',
        'Add Photos',
        'upload.cfm?id=',
        {height:350,
        width:500,
        modal:true,
        closable:true,
        draggable:true,
        resizable:true,
        center:true,
        initshow:true,
        minheight:200,
        minwidth:200 })">
 
 
 


</cfform>

<br />


</td>
  </tr>
</table>
</cfoutput>
0
Comment
Question by:overcolor
  • 10
  • 9
19 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 38795638
>   'upload.cfm?id=',

Did you mean to pass the #order_id# to the other page?  Also, a "submit" button doesn't make much sense here. Use a regular button (not submit) and show the window onClick:

<!--- sample query for testing --->
<cfset orderSKU = queryNew("")>
<cfset queryAddColumn(orderSKU, "order_ID", listToArray("AAA,BBB,CCC"))>

<!--- only do import once --->
<cfajaximport tags="cfwindow,cffileupload,cfform"  >
<cfoutput query="ordersku">

<!--- form name should be unique --->
<cfform id="test#currentRow#" name="test">
  <cfinput name="imageField" type="button" value="#order_id#" class="member_button"  
        onClick="ColdFusion.Window.create
        ('Window#order_id#',
        'Add Photos',
        'upload.cfm?id=#order_id#',
        {height:350,
        width:500,
        modal:true,
        closable:true,
        draggable:true,
        resizable:true,
        center:true,
        initshow:true,
        minheight:200,
        minwidth:200 })">
 </cfform>

<br />


</td>
  </tr>
</table>
</cfoutput> 

Open in new window

0
 

Author Comment

by:overcolor
ID: 38795666
I would like the fileuploader to know where the file should go, so I was trying to pass the #order_id#. I dont know If that is right or not, I have not that far with my code to even test
0
 
LVL 52

Expert Comment

by:_agx_
ID: 38795694
Without knowing more it sounds ok so far.

>   "but when I select the next one it has the same information as the first..."

Did the code above fix the problem? When I run it (passing #order_id# to "upload.cfm") it changes every time. ie It's working as I'd expect.  If not, can you elaborate on how it's behaving in correctly?
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

Author Comment

by:overcolor
ID: 38795713
It gives me the fileupload box on the first one I select but on the second one just a plain grey box ...no errors or fileupload.

which ever one I select first, works then the others do not
Screen-Shot-2013-01-18-at-9.23.5.png
Screen-Shot-2013-01-18-at-9.23.2.png
0
 
LVL 52

Expert Comment

by:_agx_
ID: 38795803
Yeah, I get the same result.  The ajax controls don't always play well with each other.  I think the issue here is related to using a flash control inside what's basically a div (not a real popup window).

I'm heading to sleep now, but I think you'll have to create a single window in the main page - outside the loop. Then do a hide/show instead of create().  This example is ugly but works w/cf10.

Edit Fixed example so it refreshes based on id.

<!--- sample query for testing --->
<cfset orderSKU = queryNew("")>
<cfset queryAddColumn(orderSKU, "order_ID", listToArray("11,22,33"))>

<!--- only do import once --->
<cfajaximport tags="cfwindow,cffileupload,cfform"  >

<script type="text/javascript">
	function showOrderWindow(id) {
		ColdFusion.navigate('upload.cfm?id='+ id , "OrderWindow");
		ColdFusion.Window.show('OrderWindow');
	}
</script>
<cfoutput query="ordersku">
	<!--- form name should be unique --->
	<cfform id="test#currentRow#" name="test">
  	<cfinput name="imageField" type="button" 
		value="#order_id#" 
		class="member_button"  
        onClick="showOrderWindow(#order_id#)">
 </cfform>
</cfoutput> 

  <cfwindow 
		name="OrderWindow"
        title="Add Photos"
        source="upload.cfm?id="
        height=350
        width=500
        modal=true
        closable=true
        draggable=true
        resizable=true
        center=true
		y=100
        initshow=false
        minheight=200
        minwidth=200  />
<br />

Open in new window

0
 
LVL 52

Expert Comment

by:_agx_
ID: 38795814
Scratch that last example... it wasn't refreshing the id. See my updated code above. Just change this part:

   <cfwindow  name="OrderWindow" title="Add Photos" source="upload.cfm?id="

to this instead;

    <cfwindow  name="OrderWindow" title="Add Photos" source="upload.cfm"

Night!
0
 

Author Comment

by:overcolor
ID: 38811489
I get a error one the first click of any button, then if click again it works?
0
 
LVL 52

Expert Comment

by:_agx_
ID: 38812160
Using the stand alone example with the change I added here? What's the error message?

Also what version of CF are you running? The example was tested w/CF10.
0
 

Author Comment

by:overcolor
ID: 38812705
my server is 9, Im testing on my localhost that runs 10

Im getting this

Element ID is undefined in URL.
The error occurred on line 6.

My upload.cfm page is not seeing ID, only on the first click
0
 

Author Comment

by:overcolor
ID: 38812732
Do you think this code might work o my server?
0
 
LVL 52

Expert Comment

by:_agx_
ID: 38812782
Let me test it under CF9
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 38812796
Hm... wait a sec. I'm seeing the same result under CF10, unless I remove the source="upload.cfm" from the cfwindow.  Then it seems to pass the "ID" on the first click.  Can you try it? See if it works for you too?

testPage.cfm
<!--- sample query for testing --->
<cfset orderSKU = queryNew("")>
<cfset queryAddColumn(orderSKU, "order_ID", listToArray("11,22,33"))>

<!--- only do import once --->
<cfajaximport tags="cfwindow,cffileupload,cfform"  >

<script type="text/javascript">
	function showOrderWindow(id) {
		ColdFusion.navigate('upload.cfm?id='+ id , "OrderWindow");
		ColdFusion.Window.show('OrderWindow');
	}
</script>
<cfoutput query="ordersku">
	<!--- form name should be unique --->
	<cfform id="test#currentRow#" name="test">
  	<cfinput name="imageField" type="button" 
		value="#order_id#" 
		class="member_button"  
        onClick="showOrderWindow(#order_id#)">
 </cfform>
</cfoutput> 

  <cfwindow 
		name="OrderWindow"
        title="Add Photos"
		source="upload.cfm"
        height=350
        width=500
        modal=true
        closable=true
        draggable=true
        resizable=true
        center=true
		y=100
        initshow=false
        minheight=200
        minwidth=200  />
<br />

Open in new window


Upload.cfm
<cfoutput>Upload.cfm loaded at #now()#</cfoutput>
<cfdump var="#URL#">

<cffileupload  
    url="uploadFiles.cfm" 
    progressbar="true" 
    name="myupload" 
    addButtonLabel = "Add File" 
    clearButtonlabel = "Clear it" 
    hideUploadButton = "true" 
    width=600 
    height=400 
    title = "File Upload" 
    maxuploadsize="30" 
    extensionfilter="*.jpg, *.png, *.flv, *.txt" 
    bgColor="##FFFFFF" 
    maxFileSelect=10 
    uploadButtonLabel="Upload now"/>

Open in new window

0
 

Author Comment

by:overcolor
ID: 38813031
Im still getting the error on the first click, but any other works. What did you mean when you said
>" unless I remove the source="upload.cfm" from the cfwindow"?

In the Dump, I can see the ID being passed on the second click.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 38815038
Are you testing the exact code I posted?

I meant when supply a "source" when creating the window (either of these)

          <cfwindow source="upload.cfm" ....>
          <cfwindow source="upload.cfm?id=" ...>

The test "upload.cfm" page doesn't show "ID" as a URL parameter on the 1st click.  ie It's undefined like in your error.  But when I omit "source", like in the later example, URL.ID is always defined and the error goes away.
0
 

Author Comment

by:overcolor
ID: 38815726
Ok, I got that also, let me try to make this work
0
 

Author Comment

by:overcolor
ID: 38817230
Im getting this error if I click the link on the page early.

Error replacing HTML, element not found: OrderWindow [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]

Will the page have to completely load all the query information before any of them will work?
0
 
LVL 52

Expert Comment

by:_agx_
ID: 38817386
Not the query. The cfwindow would need to finish loading though. I can't reproduce that error w/the test page.  But it sounds like the error is saying the window element doesn't exist yet. So when you call ColdFusion.navigate you get an error. But I can't be sure without seeing a screen short or the exact error message.  

Maybe try putting the <cfwindow> code before any other elements. Also verify it exists first before calling ColdFusion.navigate
0
 

Author Closing Comment

by:overcolor
ID: 38822595
I moved it above the query output and it works...thank you
0
 
LVL 52

Expert Comment

by:_agx_
ID: 38822662
Ah the fun of asynchronous javascript ;-)

Glad I could help.
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question