?
Solved

ColdFusion passing variables multiple times.

Posted on 2009-06-30
8
Medium Priority
?
392 Views
Last Modified: 2012-05-07
I am trying to pass CF Varaibles from page 1 to  execute a new query on page 2.  that is working....

Then I am trying to pass those varaibles in page 2 to a page that allows the user to save the output into excel on there desktop (page 3)

For some reason the varaibles are NOT passing to my excel page... The table headers are showing, but the query results are not... Please help....  

Code enclosed

<!------------Button from page 1 to link to page 2----->
<onClick="openActivity(Page2.cfm?in_var_one=#urlencodedformat(in_var_one)#&in_var_two=#in_var_two');return false")  value="Button1"></td>
 
<!-----on Page 2... its grabbing the varaibles from here ---->
<cfif isdefined ("url.in_var_one")>
<CFSET in_var_one = "#url.in_var_one#">
 </cfif>
 <cfif isdefined ("url.in_var_one")>
 <CFSET in_var_one = "#url.in_var_one#">
 </cfif>
<!---- this works the varaibles pass and show the output in a new window-----> 
<!---- now here is my code for saving to excel on page 2 to page 3 ----->
 
<!--- set the default to false (ie not a download )--->
<cfparam name="url.download" default="0">
 
<!--- if this is a download ...--->
<cfif url.download eq 1>
<cfheader name="Content-Disposition" value="attachment; filename=Budget.xls">
	<cfcontent type="application/vnd.ms-excel" reset="true">
</cfif>
 
 
<!---- BUTTON to link to Page 3-------> 
<!--- if this is not a download, display the button ...--->
<cfif url.download neq 1>
	<cfoutput>
	<form method="get" action="Page3.cfm?in_var_one=#urlencodedformat(in_var_one)#&in_var_two=#in_var_two#;return false;rr=#RandRange(1, 5000)#">
		<input type="hidden" name="download" value="1">
		<input type="submit" value="Export to Excel">
	</form>
	</cfoutput>
</cfif>
 
<!-----on Page 3... its grabbing the varaibles from here same as page 2 ---->
<cfif isdefined ("url.in_var_one")>
<CFSET in_var_one = "#url.in_var_one#">
 </cfif>
 <cfif isdefined ("url.in_var_one")>
 <CFSET in_var_one = "#url.in_var_one#">
 </cfif>
 
 
<!---- at the bottom of the page is my excel header to save all content in excel-----> 
<cfheader name="Content-Disposition" value="attachment; filename=Budget.xls">
<cfcontent type="application/vnd.ms-excel" reset="true">
 
<------now the page links and the excel sheet saves but the varaibles are NOT passing so the excel sheet has no data... what am I doing wrong ???? ------->

Open in new window

0
Comment
Question by:plusone3055
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 10

Expert Comment

by:js_vaughan
ID: 24745561
Try commenting out your header to see if the data shows then.  You have <cfcontent reset="true"> in there more than once; i suspect that is your problem.
0
 
LVL 22

Author Comment

by:plusone3055
ID: 24745651
should I comment

<cfheader name="Content-Disposition" value="attachment; filename=Budget.xls">

 out in page 2 or 3 ????



0
 
LVL 10

Expert Comment

by:js_vaughan
ID: 24746141
sorry, my mistake.. those were on 2 different pages.

Here is the problem : action="Page3.cfm?in_var_one=#urlencodedformat(in_var_one)#&in_var_two=#in_var_two#;return false;rr=#RandRange(1, 5000)#"

you cant pass your URL variables like this to coldfusion.  Set your variables in hidden fields.
0
What is a Denial of Service (DoS)?

A DoS is a malicious attempt to prevent the normal operation of a computer system. You may frequently see the terms 'DDoS' (Distributed Denial of Service) and 'DoS' used interchangeably, but there are some subtle differences.

 
LVL 22

Accepted Solution

by:
plusone3055 earned 0 total points
ID: 24747240
can you demonstrate for me please

I have the variables on page 3 hidden like so.....


<cfoutput>
                  <input type="hidden" name="in_var_one"  value="#in_var_one#">
                  <input type="hidden" name="in_var_two" value="#in_var_two#">



      </cfoutput>

there done the same way in page 2 coming from page 1

can you please show me how to link them through coldfusion...

thank you so much
0
 
LVL 10

Expert Comment

by:js_vaughan
ID: 24747402
See the code comment below.  I assume you are using "rr" to prevent client caching of the URL?  If so, use a time-based variable instead like demonstrated below.
You currently have this :
<form method="get" action="Page3.cfm?in_var_one=#urlencodedformat(in_var_one)#&in_var_two=#in_var_two#;return false;rr=#RandRange(1, 5000)#">
	<input type="hidden" name="download" value="1">
	<input type="submit" value="Export to Excel">
</form>
 
You need something like this :
 
<form method="get" action="Page3.cfm">
	<input type="hidden" name="download" value="1">
	<input type="hidden" name="in_var_one" value="#urlencodedformat(in_var_one)#">
	<input type="hidden" name="in_var_two" value="#urlencodedformat(in_var_two)#;">
	<input type="hidden" name="time" value="#urlencodedformat(now())#">
	<input type="submit" value="Export to Excel">
</form>

Open in new window

0
 
LVL 22

Author Comment

by:plusone3055
ID: 24747916
thank you for your demo unfortunatly it yielded the same results the table was there but the output was not
this is very strange it works fine when going from one page to another but add the excel into it doesnt pass the variavles..

any other suggestions ????
0
 
LVL 22

Author Comment

by:plusone3055
ID: 24748760
im going to give up on this and just use java
0
 
LVL 18

Expert Comment

by:Plucka
ID: 24751434
Why not just put them in session variables.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

800 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