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

if statement and HTML tags

Community Beginner ,
Nov 13, 2009 Nov 13, 2009

Copy link to clipboard

Copied

I am wanting to create an if statment like so....

<CFIF #URL.PDF# EQ 'Yes'>
<body>
<cfdocument format="pdf">
<cfelse>
<body onLoad="window.print() ">
</CFIF>

However I cannot get this to work it throws an error.  Is there a way to do this.

TOPICS
Advanced techniques

Views

638

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 ,
Nov 13, 2009 Nov 13, 2009

Copy link to clipboard

Copied

What is the value of the pdf variable and what is the error message?

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
Community Beginner ,
Nov 13, 2009 Nov 13, 2009

Copy link to clipboard

Copied

The value of the pdf is no at the end of the document I am trying to at

<CFIF #URL.PDF# EQ 'Yes'>
</CFDOCUMENT>
</CFIF>

I am trying ot use one page that the user goes to and either gets to print or PDF based on what the selected on the previous  page.

The error msg is "

Context validation error for tag CFDOCUMENT.

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
Valorous Hero ,
Nov 13, 2009 Nov 13, 2009

Copy link to clipboard

Copied

<CFIF #URL.PDF# EQ 'Yes'>

</CFDOCUMENT>

</CFIF>

You cannot split the opening and closing cfdocument tags that way, or most cf tags for that matter. The entire cfdocument must reside within the cfif tags:

<cfif URL.pdf eq "someValue">

    <cfdocument....> content </cfdocument>

</cfif>

Also, you can get rid of the extra # signs. They are not needed.

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
LEGEND ,
Nov 13, 2009 Nov 13, 2009

Copy link to clipboard

Copied

LATEST

cfsavecontent might save you some typing in this situation.

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