[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 310
  • Last Modified:

pass a date as a url variable

I have 3 cfm pages. The first is a form, from which I pass a date to the second page. No Problem.

I now want to pass that date to the third page as a url variable.

question1 - How do I construct the href statement on the second page?
question2 - What does my cfquery look like on the third page?

0
steermanma
Asked:
steermanma
  • 5
  • 3
1 Solution
 
pinaldaveCommented:
Link in the second page:
<a href="yourlink?date=#url.Id#">Click to go to third page.</a>
Query on the third page:
<cfquery your params>
SELECT * FROM MYTABLE WHERE ID = #url.ID#
</cfquery>

Regards,
---Pinal
0
 
mrichmonCommented:
well that is an interesting question.

The idea behind Pinaldave's solution works if you want a link to click from the second page to third page, but needs some syntax modification:

<a href="thirdpage.cfm?passeddate=#form.datefield#">Click to go to third page.</a>

<cfquery your params>
SELECT * FROM MYTABLE WHERE Datefield = #url.passeddate#
</cfquery>

If you want to pass it along with other form data (i.e. a form is entered on 2nd page too, but doesn't include date), but have the date in url then do

<form action="thirdpage.cfm?passeddate=#form.datefield#">

and it will pass in the URL when the submit of the second page is clicked.

(But if doing it this way I recommend a hidden variable instead of a URL variable)
0
 
steermanmaAuthor Commented:
mrichmon - I tried your 1st method, i.e.
<a href="thirdpage.cfm?passeddate=#form.datefield#">Click to go to third page.</a>

<cfquery your params>
SELECT * FROM MYTABLE WHERE Datefield = #url.passeddate#
</cfquery>

but when I click on the third page error is 'element passeddate is undefined in url'

0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
mrichmonCommented:
Did you get to the 3rd page by clicking the link "Click to go to third page"  or by submitting a form (i.e. clicking a button)?

Also what does the page URL look like in the browser

It should look like:

http://www.yourwebsite.com/thridpage.cfm?passeddate=4/4/2005

(Or whatever date was entered in the page1 form)
0
 
steermanmaAuthor Commented:
Looks just like that, except was using '>' instead of '='. The equal works. Do you have any idea what the 3rd page query would look like if on the 2nd page I said

<a href="thirdpage.cfm?passeddate between#form.datefield1# and #form.datefield2#">
0
 
mrichmonCommented:
I have no idea why you would have put a > instead of =

The URL is not a place where you can put comparisons.  Only variablename = value pairs

SO if what you were trying to do is find where the date was greater than the one you sent you need to put the > in the query on the third page:

<a href="thirdpage.cfm?passeddate=#form.datefield#">Click to go to third page.</a>

<cfquery your params>
SELECT * FROM MYTABLE WHERE Datefield > #url.passeddate#
</cfquery>

You also can't use "and" or "between"

It works like this:

page.cfm?var=value&var=value&var=value




You need to understand that the URL is not a query.  You only pass values and then assemble them into the conditions on the page that recieves them.

Like this:
Page2:
<a href="thirdpage.cfm?date1=#form.datefield1#&date2=#form.datefield2#">Click</a>

Then Page3

<cfquery your params>
SELECT * FROM MYTABLE WHERE date between #url.date1# and #url.date2#
</cfquery>

Of course if this is access then it needs to be:

<cfquery your params>
SELECT * FROM MYTABLE WHERE date between ###url.date1### and ###url.date2###
</cfquery>
0
 
mrichmonCommented:
In general you may want to be careful about 2 things:

1) You marked the question as answered and then kept asking questions.  Many experts will not appreciate this nor continue to help you with the question.  Once a question is answered it is better ettiquite to post a new one for further questions.

2) A grade of B indicates that the solution posted helped, but you needed more information for a complete solution.  Before giving out a B grade try to allow the experts to help you completely and you will find more people willing to help you in the future.


Best of luck.
0
 
steermanmaAuthor Commented:
Thanks mrichmon, you've been very helpful, and your advice has been noted by an Experts Exchange newbie...
0
 
mrichmonCommented:
Not a problem.  Glad to be of assistance.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now