Solved

Cfwindow not working in a query output

Posted on 2013-01-18
19
713 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_
Comment Utility
>   '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
Comment Utility
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_
Comment Utility
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
 

Author Comment

by:overcolor
Comment Utility
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_
Comment Utility
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_
Comment Utility
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
Comment Utility
I get a error one the first click of any button, then if click again it works?
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

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

Expert Comment

by:_agx_
Comment Utility
Let me test it under CF9
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
Comment Utility
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
Comment Utility
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_
Comment Utility
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
Comment Utility
Ok, I got that also, let me try to make this work
0
 

Author Comment

by:overcolor
Comment Utility
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_
Comment Utility
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
Comment Utility
I moved it above the query output and it works...thank you
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
Ah the fun of asynchronous javascript ;-)

Glad I could help.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now