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
Nick KeehanNick Keehan 

Visualforce JS call not working Oncomplete

Hey guys.

Looking for some help with my JS firing.

Oncomplete doesnt seem to fire my script. Any Ideas?
 
<apex:page controller="SubmitLeadController" showHeader="false"  >
<html>
    <apex:form >
        <apex:pageMessages />
        
     
    <body> 
        
        <table style="width:800px; margin: 20px;" >
    <apex:slds />





         <tr >
         <th style="padding: 10px; text-align: left;">Request Details</th>
         </tr>   

            
              <tr style="border-bottom: 1px solid #ddd;" >
                <th style="padding: 10px; text-align: left; font-weight: normal;">Request Type</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Request_Type__c}" id="Request_Type__c" required="true" style="width:200px;"/></td>
            </tr>              
              
 
         <tr >
         <th style="padding: 10px; text-align: left;">Customer Details</th>
         </tr>         
          
          
            <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">CRM type</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.CRM__c}" id="CRM__c" required="true" style="width:200px;"/></td>
            </tr>
            
            
            <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">Customers Account Number:</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Account_number__c}" id="Account_Number__c" required="true" style="width:200px;"/></td>
            </tr>
            
            
            <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">First Name:</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.FirstName}" id="FirstName" required="true" style="width:200px;"/></td>
            </tr>
   
   
             <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">Last Name:</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.LastName}" id="LastName" required="true" style="width:200px;"/></td>
            </tr>  
            
            
             <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">Email Address:</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Email}" id="Email" style="width:200px;"/></td>
            </tr>             
            
            
            <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">Contact Number:</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Phone}" id="Phone" required="true" style="width:200px;"/></td>
            </tr>
 
 
             <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">Alternative Contact Number:</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Alternative_Phone_No__c}" id="Alternative_Phone_No__c"  style="width:200px;"/></td>
            </tr>
 
            
            <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">Callback Time</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Best_Time_To_Call__c}" id="Best_Time_To_Call__c" required="true" style="width:200px;"/></td>
            </tr>              
 
 
             <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">Current Broadband Provider</th>
                <td style="padding: 10px; text-align: left;"><apex:inputtext value="{!c.Broadband_Provider_Details__c}" id="Broadband_Provider_Details__c" required="true" style="width:200px;"/></td>
            </tr>  
 
            
            <tr>
                <th style="padding: 10px; text-align: left; font-weight: normal;">Contract Status</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Contract_Status__c}" id="Contract_Status__c"  style="width:200px;"/> </td>                              
            </tr>    
  
  
             <tr  >    
                <th style="padding: 10px; text-align: left; font-weight: normal;"></th>               
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Contract_end_date__c}" id="Contract_end_date__c"  style="width:200px;" /></td>                    
             </tr>
 
              <tr style="border-bottom: 1px solid #ddd;" id="test1">    
                <th style="padding: 10px; text-align: left; font-weight: normal;"></th>               
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Contract_End_Date_Call_Back_Year__c}" id="Contract_End_Date_Call_Back_Year__c2" style="width:200px;" /></td>                     
             </tr>
 
            

             <tr style="border-bottom: 1px solid #ddd;">
                <th style="padding: 10px; text-align: left; font-weight: normal;">Notes - Be as clear as possible for the person picking up this call-back</th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Comments__c}" id="Comments__c" style="width:200px;" /></td>
            </tr>           
            
            
            
                        <tr style="border-bottom: 1px solid #ddd;" >
                <th style="padding: 10px; text-align: left; font-weight: normal;">Your Email Address: </th>
                <td style="padding: 10px; text-align: left;"><apex:inputfield value="{!c.Referred_By_Email__c}" id="Referred_by_email__c" required="true" style="width:200px;"/></td>
            </tr>      
                  
                  
       <!-- ***** Marketo embed snippet ***** -->
    <!-- Marketo embed script -->
    <script src="//app-sn04.marketo.com/js/forms2/js/forms2.min.js"></script>
    <script type="text/javascript">
        (function() {
            var didInit = false;
            function initMunchkin() {
                if (didInit === false) {
                    didInit = true;
                    Munchkin.init('727-LUR-661');
                }
            }
            var s = document.createElement('script');
            s.type = 'text/javascript';
            s.async = true;
            s.src = '//munchkin.marketo.net/munchkin.js';
            s.onreadystatechange = function() {
                if (this.readyState == 'complete' || this.readyState == 'loaded') {
                    initMunchkin();
                }
            };
            s.onload = initMunchkin;
            document.getElementsByTagName('head')[0].appendChild(s);
        })();
        var m_obj = [];
        MktoForms2.loadForm("//app-sn04.marketo.com", "727-LUR-661", 1052, function (form) {
            m_obj.form = form;
        }).whenReady(function (form) {
            form.onSuccess(function (values, followUpUrl) {
                console.log(values); // FOR DEBUGGING - REMOVE WHEN NEEDED
                return false;
            });
        });
        function m_submit() {
            m_obj.form.setValues({
                "CallBackForm_ClarifyBillingAccountID": document.getElementById("Account_number__c").value, // Clarify Account Number
                "FirstName": document.getElementById("FirstName").value, // First Name
                "LastName": document.getElementById("LastName").value, // Last Name
                "callBackFormBroadbandProviderDetails": document.getElementById("Broadband_Provider_Details__c").value, // Current Broadband Provider
                "callBackFormContractenddate": document.getElementById("Contract_end_date__c").value, // Contract End Date
                "callBackFormContractEndYear": document.getElementById("Contract_End_Date_Call_Back_Year__c").value, // Contract End Year
                "callBackFormPhoneNumber": document.getElementById("phone").value, // Contact number
                "callBackFormAltPhoneNumber": document.getElementById("Alternative_Phone_No__c").value, // Alternative Contact Number
                "callBackFormCallBackTime": document.getElementById("Best_Time_To_Call__c").value, // Best Time to Call
                "callBackFormRequestType": document.getElementById("Request_Type__c").value, // Customers Request
                "callBackFormComments": document.getElementById("Comments__c").value, // Notes
                "Email": document.getElementById("Email").value, // Email
                //"callBackFormReferredByEmail": document.getElementById("Referred_By_Email__c").value, // referred by email (unsure of source)
            });
            m_obj.form.submit();
        }
    </script>
    <!-- Marketo Form -->
    <form id="mktoForm_1052" style="display:none"></form>
    <!-- ***** END Marketo embed snippet ***** -->               
  
   
                  
                  
            <tr>
                <td style="padding: 10px; text-align: left;"><apex:commandButton value="Submit Call-Back" action="{!submitCase}" onclick="m_submit();" /></td>
            </tr>


    
        </table>  
              
          </body>       
  
  

        
    </apex:form>
  </html>  
</apex:page>