Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two Javascript functions:

<script>

function confirmTransfer() {
  var tasks = "{!totalTasks}";
  var matches = "{!totalMatches}";
  var contacts = "{!totalContacts}";

  var transfer = confirm("Are you sure you wish to transfer: " + 
    tasks + " tasks, " + matches + " matches, and " + contacts " contacts?");

  if (transfer) return true;
  return false;
}  

function confirmCancel() {
  var isCancel = confirm("Are you sure you wish to cancel?");
  if (isCancel) return true;

 return false;
}
</script>

for some reason, just the confirmCancel function does what I want it do. The confirmTransfer button simply goes sstraight to the function call in the commandButton:

<apex:commandButton action="{!cancel}" value="Cancel" 
onclick="return confirmCancel()"immediate="true"/>    
<apex:commandButton action="{!step4}"  value="Transfer" 
onclick="return confirmTransfer()" immediate="true"/>

When I click Transfer, I see this in the console: transfercontacts:137 Uncaught ReferenceError: confirmTransfer is not defined

The syntax is the same, can anyone explain what this could be?

Thanks in advance!

share|improve this question
up vote 4 down vote accepted

It looks like you are missing a + here:

contacts + " contacts?"

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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