Skip to main content
Inspiring
April 30, 2010
Question

How do I get choice between two url.locations in script?

  • April 30, 2010
  • 2 replies
  • 1280 views

I want to have a select statement take me to one page if the Type 2 is selected, and a different page if Type 1. I've tried what follows, but it just goes to the last cflocation url listed. Is there a way to actually have the if/else work so if it's "2" it goes to rinfo2.cfm and if "1" or anything else, it goes to rfino1.cfm?

- - - - - - -
THIS WORKS BUT DOESN'T GIVE ME THE CHOICE I WANT.
<cfif isDefined("URL.type")>
<cfquery name="rsFindType" datasource="holly">
select * from rcontacts10 where type="2"
</cfquery>
<cflocation url="rinfo2.cfm">

<cfelse>
<cfquery name="rsFindAllTypes" datasource="holly">
select * from rcontacts10
</cfquery>
<cflocation url="rinfo1.cfm">
</cfif>
- - - -

Thanks!

    This topic has been closed for replies.

    2 replies

    tharringAuthor
    Inspiring
    April 30, 2010

    Excuse me, I mean "add some type of test on the VALUE of the URL.TYPE variable." I don't know how to add a test to that variable. An example would be of great help.

    Thanks.

    ilssac
    Inspiring
    April 30, 2010

    Your test is IF a url variable name type is defiend do this query and go to URL one


    ELSE

    do that query and go to URL two.

    You probably want to include a clause in your IF statement that does some type of test on the VALUE of the URL.TYPE variable.

    tharringAuthor
    Inspiring
    April 30, 2010

    I've been looking at how to scope a variable but all I've come up with is how to add a variable to an "isDefined" statement: <cfif isDefined("var_A"). I'd sure like to know how to "add some type of test on the VALUE of the URL". Could you please give me an example. I'm a totally logical programmer and can understand code but can't come up with it on my own. Thanks so much.

    BKBK
    Community Expert
    Community Expert
    April 30, 2010

    Use:<cfif isDefined("URL.type") and URL.type EQ 2>

    That condition will be true if the client enters a URL like http://blablabla.com/xyz.cfm?type=2, and false otherwise.