You need to sign in to do that
Don't have an account?
George M Albrecht
Javascript Popup on VF Page from Static Resource
Hello,
New to using JS, we have a need on a VisualForce page when the label of a pageBlockSectionItem is clicked, to execute a JS popup. In order to keep the code clean, I have put the JS in a seperate static resource. I am now trying to access a function for the onLabelClick and it is not working. If I put the <script> tags in the VF page and invoke the fuction onLabelclick it works, but is there a way to avoid that?
Below is the VF code I have that is not working:
New to using JS, we have a need on a VisualForce page when the label of a pageBlockSectionItem is clicked, to execute a JS popup. In order to keep the code clean, I have put the JS in a seperate static resource. I am now trying to access a function for the onLabelClick and it is not working. If I put the <script> tags in the VF page and invoke the fuction onLabelclick it works, but is there a way to avoid that?
Below is the VF code I have that is not working:
<apex:page standardController="QA__c"> <apex:includeScript value="{!$Resource.QA_Javascript}"/> <apex:form > <apex:pageMessages /> <apex:pageBlock title="QA Scoring Form"> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save" /> <apex:commandButton action="{!cancel}" value="Cancel"/> </apex:pageBlockButtons> <apex:actionRegion > <apex:pageblockSection title="QA Information"> <apex:inputField value="{!QA__c.Reviewee__c}"/> <apex:inputField value="{!QA__c.Complexity__c}"/> <apex:inputField value="{!QA__c.QA_Quote_Number__c}"/> <apex:inputField value="{!QA__c.QA_Date__c}"/> <apex:inputField value="{!QA__c.Overall_Comments__c}"/> </apex:pageblockSection> <apex:pageBlockSection title="Phone Etiquette" id="pe"> <apex:pageBlockSectionItem onLabelclick="appGreet();" > <apex:outputLabel value="Appropriate Greeting" for="ag1"/> <apex:panelGrid columns="2"> <apex:inputField value="{!QA__c.Appropriate_Greeting__c}" id="ag1"> <apex:actionSupport event="onchange" reRender="pe"/> </apex:inputfield> <apex:inputField value="{!QA__c.App_Greet_Comment__c}" id="ag2" label="Comments"/> </apex:panelGrid> </apex:pageBlockSectionItem>
<script>
var accountId = '{!JSENCODE(accountId)}';
</script>
// you will be able to access accountId variable in your static resource now
<apex:includeScript value="{!$Resource.QA_Javascript}"/>
If the problem still exists, then please post your JavaScript code so that the community can better assist you.