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

x
?
Solved

adding a CFIF to a CFINPUT tag

Posted on 2004-11-17
10
Medium Priority
?
990 Views
Last Modified: 2013-12-24
I want to define a CFIF tag insdie a CFINPUT tag to add required=yes everytime that a specific condition was satisified, but CF through an error :

Invalid token 'c' found on line 363 at column 98.  
The CFML compiler was processing:

a cfinput tag beginning on line 363, column 24.
a cfinput tag beginning on line 363, column 24.
 
 
Any idea ?
0
Comment
Question by:Michael_O
10 Comments
 
LVL 21

Expert Comment

by:pinaldave
ID: 12604842
As per I have experience.
This does not work for me.
What I do here is that...
<cfif my condtion>
<cfinsert with some inserts>
</cfelse>
<cfinsert with more inserts>
</cfif>

Regards,
---Pinal
0
 
LVL 5

Expert Comment

by:kkhipple
ID: 12605139
just as pinal suggested use

<CFIF statement>
  <CFINPUT ... required = "yes" >
<CFELSE statement>
  <CFINPUT ... required = "no" >
</CFIF>
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 12605680
You cannot nest cold fusion tags

But you can use a regular input tag with a nested cfif - which is not what you asked, but is probably a better way to go in the long run - not using cfinput or cfform - but writing actual HTML elements.

<input <cfif ....></cfif>>
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
LVL 5

Expert Comment

by:kkhipple
ID: 12605761
if Michael_O ends up writing actual HTML elements, then javascript will be needed for any client validation such as making sure user has filled out a particular input (required = yes).
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 12605984
Yes it would, but it would be more robust, effective, and all around better code.

Notice that I said "in the long run" because this is not a trivial task, but does make you end up with a better application less prone to the bugs in cfform and more user friendly than the automatically written validation for cfinputs.
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 12605990
Note that javascript is needed even with cfinput - COld Fusion just does most of it for you....
0
 
LVL 15

Accepted Solution

by:
danrosenthal earned 1600 total points
ID: 12606438
You can also use YESNOFORMAT(), for instance...

<CFINPUT name="test" required="#yesnoformat(testvalue eq 3)#">
0
 
LVL 6

Expert Comment

by:mosphat
ID: 12607174
You can use iif() to have cfif-like functionality in CF-tags. But if it comes to performance and readability, pinaldave had the correct solution:

<cfif my condtion>
<cfinsert with some inserts>
</cfelse>
<cfinsert with more inserts>
</cfif>
0
 

Expert Comment

by:DotSPF
ID: 12615855
I find a useful solution is defining the text like so:

<cfif condition>
    <cfset inputtext = "required=yes">
<cfelse>
    <cfset inputtext = "">
</cfif>

Then include the inputtext variable inside the cfinput tag.
0
 

Author Comment

by:Michael_O
ID: 12633152
Hello danrosenthal,

I think your answer is the best one. Thank you for you participation.
0

Featured Post

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.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

834 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