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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using CSS within CFIF Statements??

Status
Not open for further replies.

ma701sd

IS-IT--Management
Dec 15, 2000
94
GB
Hi, can anyone help with this Prob??

What Im trying to do is to set a variable using many CFIF statements. Enclosed within the CFIF Statements, I am trying to set a variable for CSS. It looks something like this:

<CFIF ISDEFINED ('form.heading') AND ISDEFINED ('Form.X') AND ISDEFINED ('form.Y')>
<CFSET HeadingX=&quot;#X#&quot;>
<CFSET HeadingY=&quot;#Y#&quot;>

<STYLE TYPE=&quot;text/css&quot;>
#positionheading
{
position:absolute;
top: <CFOUTPUT>#HeadingX#</cfoutput>px;
left: <cfoutput>#HeadingYY#</cfoutput>px;
}
</style>

<CFELSEIF ISDEFINED ('form.Section1Heading1') AND ISDEFINED ('Form.X') AND ISDEFINED ('form.Y')>
<CFSET Section1Heading1X=&quot;#X#&quot;>
<CFSET Section1Heading1Y=&quot;#Y#&quot;>

<STYLE TYPE=&quot;text/css&quot;>
#positionSection1Heading1
{
position:absolute;
top: <CFOUTPUT>#Section1Heading1X#</cfoutput>px;
left: <cfoutput>#Section1Heading1Y#</cfoutput>px;
}
</style>


ETC ETC,
However, WHen Coldfusion starts to process the CFIF statements, it fails when it encounters the curly Brackets &quot;{&quot;. Are these not allowed within CFIF statements?

Am I doing something wrong or is there a work-around?

If any1 has any ideas, I would really appreciate it..

Many thanks

Sam...
 
I'd guess you're getting an invalid parser error. If that's what you're getting, you probably have a <cfoutput> tag somewhere above this block of code and it's looking at #positionheading as a field and obviously getting messed up when it finds the bracket. I can't see any other way that the bracket would return an error. Andrew
 
##positionheading
and it'll work !
(i've used cf & css the way you want to !)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top