Cfwindow not working in a query output

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>
overcolorAsked:
Who is Participating?
 
_agx_Commented:
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
 
_agx_Commented:
>   '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
 
overcolorAuthor Commented:
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
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
_agx_Commented:
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
 
overcolorAuthor Commented:
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
 
_agx_Commented:
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
 
_agx_Commented:
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
 
overcolorAuthor Commented:
I get a error one the first click of any button, then if click again it works?
0
 
_agx_Commented:
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
 
overcolorAuthor Commented:
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
 
overcolorAuthor Commented:
Do you think this code might work o my server?
0
 
_agx_Commented:
Let me test it under CF9
0
 
overcolorAuthor Commented:
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
 
_agx_Commented:
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
 
overcolorAuthor Commented:
Ok, I got that also, let me try to make this work
0
 
overcolorAuthor Commented:
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
 
_agx_Commented:
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
 
overcolorAuthor Commented:
I moved it above the query output and it works...thank you
0
 
_agx_Commented:
Ah the fun of asynchronous javascript ;-)

Glad I could help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.