Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cfinput value problem 2

Status
Not open for further replies.

uconn1981

Programmer
Mar 21, 2005
42
US
Hi,
I have the follow code.

<cfinput type="text" name="dtLeave" label="Start:" width="200" required="yes" value="<cfif IsDefined('session.startdate')>1/2/2002</cfif>" validate="date" message="Please enter date format mm/dd/yyyy.">

The problem is the cfif for value does not work. The "<cfif IsDefined('session.startdate')>1/2/2002</cfif" will appear in the field instead of 1/2/2002.

Thanks,
Tim
 
You can't use a cf tag inside a cf tag. Since you're using cfinput, you'll need to do something like this:
Code:
<cfif IsDefined('session.startdate')>
  Input tag with date as VALUE
<cfelse>
  Input tag without date as VALUE
</cfif>
If you were to change it to a regular input tag, your cfif statement would work fine inside of it.


Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
<cfif IsDefined('session.startdate')>
variables.startDate = session.startdate
<cfelse>
variables.startDate = ""
</cfif>

<cfinput type="text" name="dtLeave" label="Start:" width="200" required="yes" value="#variables.startData#" validate="date" message="Please enter date format mm/dd/yyyy.">

 
or you can use the IIF function. its a cfif but its a function instead of a tag.

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
i never liked dealing with the evaluation of the iif, but it does work. about the only thing I think i ever use it for is alternating row colors in divs or table rows. :)

 
that's what de() is for.

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
I thought that was only pre MX versions.
I just think it's clumsy when we are working in a tag based syntax, expecialy to need to use dynamic evaluate de()

I've read about it being unreliable also, but not sure about what situations that would be refering to.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top