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

javascript var for cf tag to read

New Here ,
Apr 02, 2008 Apr 02, 2008

Copy link to clipboard

Copied

I'm having trouble getting coldfusion to read my javascript output for coldfusion to process.

I am generating a list of records based on a query. Every record is written inside a table. Each table's height is undetermined until the data is generated. However, I get this number (each table's height) by calling a javascript function. My goal is to output a pdf page that is generated dynamically based on a query to print without a record spilling onto the next page. This I can accomplish by placing <cfdocumentitem type=pagebreak> at appropiate places. However, when I call my javascript function to write a cfdocumentitem tag, coldfusion throws an error alerting that this tag needs to be inside a cfdocument tag. Now we all know that javascript doesn't work inside a cfdocumet tag which is why I am placing it outside of these tags, saving it to cfsavecontent tag and loading this inside the cfdocument tag. I tried replacing the <> (opening and closing angle brackets) with &lt; and &gt; and it bypasses coldfusion's error page but then coldfusion doesn't process my cfdocument tag.

Below is just my javascript code to simplify my code. I can provide the rest if necessary.

Can anybody help?

Cesar

-------------------------------------------------------------------------------

<script language="JavaScript" type="text/javascript">
<!--

function getHeight(table)
{
var myHeight = window.document.getElementById(table).offsetHeight;
if (myHeight == 136) {
document.write('<cfdocumentitem type = "pagebreak" />');
}
}
//-->
</script>
TOPICS
Advanced techniques

Views

483

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 ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

javascript runs on the client after cold fusion has done what it has to do. move your getHeight function to cold fusion.

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 ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

Move my height to coldfusion??? How can coldfusion pre-determine the height value when the table hasn't been process? Could you provide an example of moving my height to coldfusion?

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 ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

> document.write('<cfdocumentitem type = "pagebreak" />');

I don't think you ought to expect the CF server to know about CFML that's
being output on the client browser... ;-)

have a read of my response to this thread - < http://tinyurl.com/2e3lwn>
< http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=3&threadid=812773&arcta...
- for an explanation as to how CF and the client application play with each
other.

--
Adam

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 ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

Instead of looking at the height, try looking at how may rows of data you are going to put on each page.

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 ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

Because I have some td wrapped around cfif tags to check for empty fields, I don't have full control over how many rows of data will appear. Which is why I'm placing each record inside a table and determining the height of each table through javascript.

I'm toying with the idea of sending the height information of each record back to the server so coldfusion can collect the height attribute of each record and calculate where to write cfdocumentitem type=pagebreak. But I'm not sure how to accomplish this.

Any ideas. Please advice.

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
Contributor ,
Apr 04, 2008 Apr 04, 2008

Copy link to clipboard

Copied

LATEST
You probably will have to be very recursive with this one. Output it. Check the height. Store the height in a form field. Send it back to the server so CF can read the form field and put it in the right place.

Just a thought. I've never tried to do it that way.

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