+ Start a Discussion

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">




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


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();


Thank you for your response,


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


Yes, it has to be.


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


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



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