function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DorazineDorazine 

Basic JavaScript Help

I have a basic quote app that generates a PDF from Visualforce markup. One of the field in the quote needs to be calculated from data in the quote. I hit a wall with JavaScript. This won’t even write "test":

 

<script language="text/javascript">

document.write("Test");

</script>

 

Also I’m not to clear on how to interact with Visualforce variables in JavaScript, do I need to use the brackets and exclamation point? Is what I am trying to do even possible?

 

Thanks in advanced,

David Orazine

MANATTWebMANATTWeb

It is possible and I think you just need <script> tags - no language info. For VF variables, you'll need the {!variable} to reference it. For testing, use an alert();

DorazineDorazine

Thank you for your response,

 

But it still seems to be ignoring my script. Can it be inside the apex:page tag?

MANATTWebMANATTWeb

Yes, it has to be.

DorazineDorazine

Apparently JS only does not work with rendas equal to PDF :/ Any work around?

aballardaballard

javascript does not execute when generating a pdf in visualforce.   See the documentation for this and other restrictions.

http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_quick_start_renderas_pdf.htm#kanchor186

 

You will need to put your logic in an apex controller or extension, or perhaps use a formula field.