0

Here is the code that i written:

<script> 
function myFunction(var num) 
{ 
 alert("Claim form has been successfully created with reference number:" + num); 
} 

<apex:commandButton action="{!submit}" value="Submit" oncomplete="myFunction({!Case.Claim_Reference__c});"/>
  • Do you have any javascript errors in your console? Your oncomplete should be this at the very least: oncomplete="myFunction('{!Case.Claim_Reference__c}');" – Richard Durrant Apr 1 '14 at 8:39
  • Are you using StandardController or a custom controller? Can you post the code? – highfive Apr 1 '14 at 8:39
  • When writing JavaScript you need to check your browser's console which is where JavaScript errors are reported. In Chrome this is Tools -> Developer Tools -> Console. You can even paste your function in the console and see an error. – Keith C Apr 1 '14 at 8:41
  • I am using standard controller. – Vishwesh Prabhakar Apr 1 '14 at 8:44
  • I have some javascript errors and it always points to the myfunction line in script – Vishwesh Prabhakar Apr 1 '14 at 8:45
2

Add single quote when you call your field. Also if you set your Clain_Reference__c into your submit method, you will need to reRend your button or the section.

<apex:commandButton action="{!submit}" value="Submit" oncomplete="myFunction('{!Case.Claim_Reference__c}');"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.