A cleaner way to do this is to place your cfif block just before your
cflocation tag, and write your URL QueryString to a variable there.  Then
append that variable to the url in your cflocation tag.  If the variables
being appended might have spaces or special characters in them, be sure to
perform URLEncodedFormat() on the variable before appending it.

~Simon

> Simon Horwith
> Allaire Certified ColdFusion Instructor
> Certified ColdFusion Developer
> Fig Leaf Software
> 1400 16th St NW, # 220
> Washington DC 20036
> 202.797.6570 (direct line)
> www.figleaf.com
> 


-----Original Message-----
From: Stephenie [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 01, 2001 12:09 PM
To: CF-Talk
Subject: OT: cfif statements in a cflocation tag=icky url


i have a form which takes a few input fields, then passes them to a 2nd
template for evaluation, a url is built that needs to include the variables
from the form if they exist, which is then sent via cflocation to a 3rd
template for the appropriate action.

on the 2nd template, i am using cflocation with a few cfif statements inside
it to determine if the form fields were present and build the url
accordingly, if i enter a line break before the cfif, cf does not pass the
values in the url, the only way it seems to want to work is if i run the
whole thing together,

cf includes the passed variables in the url, but the url looks terrible as
it includes the cfif code....

please tell me i am missing something obvious or there is a cleaner way to
do this.

-------cf code---------------
<cflocation
url="http://#attributes.serverip#/mydir/mytemplate.cfm?username=#attributes.
username#<cfif
#isDefined("attributes.dsn1")#>&dsn1=#attributes.dsn1#<cfelseif
#isDefined("attributes.dsn2")#>&dsn2=#attributes.dsn2#<cfelseif
#isDefined("attributes.dsn3")#>&dsn3=#attributes.dsn3#</cfif>">
-------------------------------

------------url produced from above code-------------------
http://serverip/mydir/mytemplate.cfm?username=user23<cfif%20YES>&dsn1=blah1<
cfelseif%20YES>&dsn2=blah2<cfelseif%20YES>&dsn3=blah3</cfif>
-----------------------------------------------------------
(serverip was edited for this post)

--
Stephenie Hamilton
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to