Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
grndvl1 #1
Dynamically Build a Tag
I want to dynamically build a tag using conditionals for example;
<cfmail <cfif condition EQ 1>CC="#myvar#" <cfelse> BCC=#myvar#</cfif> ....>
Any idea how to do this would be helpful since I get this error and can't
seem to figure what the work around is:
" Invalid token found on line 229 at position 4. ColdFusion was looking at the
following text:
<
Invalid expression element. The usual cause of this error is a misspelling in
the expression text."
grndvl1 Guest
-
How to build populate datagrids dynamically
The data returned from the server in my flex app is one-dimensional: A 1 xyz A 2 abc A 3 pqr I want to put this data into a datagrid so... -
Managing ViewState of a dynamically created Custom Composite Server Control -(where the original is also dynamically created)
Ok here's my scenario. I have a Custom Composite Server Control (CCSC) consisting of a TextBox, Button & Panel. (And some other code - which I... -
dynamically build sql based on text in textbox and dropdownbox
I have a web form that contains textboxes for first name and last name. I also have a dropdown list that contains companies. I would like the... -
Best way to build a form dynamically
Hello Control Builders:: Part of the form that I am designing has to be built dynamically. I ultimately want to create a set of controls that are... -
Dynamically build RangeValidation control for text box
Hello I am building a textbox control dynamically. I need to check if the value entered in the text box has a specified minimum number of... -
dempster #2
Re: Dynamically Build a Tag
AFAIK, you can't embed CF tags within another tag in order to dynamically
select which attributes to set.
Using your condition, you could set values for the CC and BCC attributes and
make one of them blank depending on the condition. I tested the attached code
and it seems to work fine.
-Paul
<CFIF condition EQ 1>
<CFSET ccstring = myvar>
<CFSET bccstring = "">
<CFELSE>
<CFSET ccstring = "">
<CFSET bccstring = myvar>
</CFIF>
<CFMAIL TO="#tostring#" FROM="mymail@myserver.com" CC="#ccstring#"
BCC="#bccstring#" SUBJECT="Test">
Here's a mail test.
</CFMAIL>
dempster Guest
-
grndvl1 #3
Re: Dynamically Build a Tag
Problem is the custom tag I am using errors out when one of the attributes is "". Anyway isn't there a way to do it with Evaluate()??
grndvl1 Guest
-
mate of the state #4
Re: Dynamically Build a Tag
How about... in your custom tag, use a switch or other conditional statement to invoke different "styles" of <CFmail> depending on the conditions... ?
mate of the state Guest
-
grndvl1 #5
Re: Dynamically Build a Tag
Sorry CFMAIL is only the example I was using not the actual tag that is causing
me pains, just used this to illustrate what I was talking about. Anyway no way
to code the custom tag myself since it is encoded. Also too many conditions
to cleanly do it. Might build the a string then use Evaluate on it to render
the tag, never tried that before....hmmm.
grndvl1 Guest



Reply With Quote

