• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script within a cfset variable

New Here ,
Mar 07, 2007 Mar 07, 2007

Copy link to clipboard

Copied

Hi,

Is it possible to hold the following code within a coldfusion variable to be outputted on a page?...

<style type="text/css">
#strap {
background-image: url(images/mypic.jpg);
}
</style>

I would like to be able to dynamically change the background image on demand.

Thanks
TOPICS
Advanced techniques

Views

287

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 07, 2007 Mar 07, 2007

Copy link to clipboard

Copied

Is it possible to hold the following code within a coldfusion variable
to be outputted on a page?


Sure, no problem.

.
.
.
.
.
.
.

Oh, would you like a suggestion on how?

<cfoutput>
<cfsaveContent variable="styleBlock">
<style type="text/css">
##strap{
background-image:url(#imageVar#);
}
</style>
</cfoutput>


<cfoutput>#styleBlock#</cfoutput>

Note: the escaping of the pound-sign id symbol since this code is inside
an output block.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 08, 2007 Mar 08, 2007

Copy link to clipboard

Copied

LATEST
Hi Ian,

Great just the job many thanks I will play about with this tag.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation