Why won't this print script and href pass <cfoutput>

I'm taking out the cfoutput because I'm so frustrated. I can't figure out what is breaking down here. This WILL NOT print with the cfoutput and # tags in this href. I take them out and the script works fine.

Here's the script:

<script type="text/javascript">
function ClickHereToPrint(val){
   try{ 
       var oIframe = document.getElementById('ifrmPrint');
       var oContent = document.getElementById('divToPrint').innerHTML;
       var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
       if (oDoc.document) oDoc = oDoc.document;
		oDoc.write("<html><head><title>"+val+"</title>");
		oDoc.write("</head><body onload='this.focus(); this.print();'>");
		oDoc.write(oContent + "</body></html>");	    
		oDoc.close(); 	    
   }
   catch(e){
	    self.print();
   }
}
</script>

Open in new window


And here's where it is called

<div style="width:100%;float:left;clear:both" id="divToPrint" class="bodyTxtBlackNoPadding">

<td style="border-bottom:1px solid #F00" align="right" valign="top"><a style="padding-right:px;" onclick="ClickHereToPrint('<cfoutput>#session.providername# Employee Medical Expiration Summary Report</cfoutput>');" href="javascript:;"><img src="../../assets/imgs/Real Vista/General/png/NORMAL/48/printer_48.png" width="48" height="48" border="0"></a></td>

<iframe id='ifrmPrint' src='##' style="width:0px; height:0px;"></iframe>

Open in new window


Any advice would be much appreciated. I'd love to carry over the name to the print page, but it appears I may not be able to do so. Thanks in advance!
tryportAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

_agx_Commented:
This worked for me

<!--- sample for testing --->
<cfset session.providername = "something">

<script type="text/javascript">
function ClickHereToPrint(val){
   try{ 
       var oIframe = document.getElementById('ifrmPrint');
       var oContent = document.getElementById('divToPrint').innerHTML;
       var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
       if (oDoc.document) oDoc = oDoc.document;
		oDoc.write("<html><head><title>"+val+"</title>");
		oDoc.write("</head><body onload='this.focus(); this.print();'>");
		oDoc.write(oContent + "</body></html>");	    
		oDoc.close(); 	    
   }
   catch(e){
	    self.print();
   }
}
</script>
<div style="width:100%;float:left;clear:both" id="divToPrint" class="bodyTxtBlackNoPadding">
<cfoutput>
<td style="border-bottom:1px solid ##F00" align="right" valign="top"><a style="padding-right:px;" onclick="ClickHereToPrint('#session.providername# Employee Medical Expiration Summary Report');" href="javascript:;"><img src="../../assets/imgs/Real Vista/General/png/NORMAL/48/printer_48.png" width="48" height="48" border="0"></a></td>
</cfoutput>
<iframe id='ifrmPrint' src='#' style="width:0px; height:0px;"></iframe>

Open in new window

tryportAuthor Commented:
Thanks for trying it. Would an ' in the session.providerName cause problems, perhaps?
_agx_Commented:
Most likely.  I never nest cfoutput tags inside other stuff, but my guess is that enclosing it in quotes prevents the CF engine from evaluating it as CFML code/tags.  Moving it outside (like in my example above) allows it to work correctly. Just don't forget to escape the # signs where needed:

<cfoutput>
       <td style="border-bottom:1px solid ##F00" align="right" valign="top">... '#session.variableName# Other text'....</td>
</cfoutput>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.