I am calling javascript function from apex:inputfield and also doing rerendering page same block section Item using action support as I am using depended picklist on my Visual Force page.

but after adding this

 <apex:actionSupport event="onchange" reRender="pbsiType" /> 

it has stopped calling my javascript function on change of value event.

Below is the code I am using fro Page block section item

<apex:pageBlockSectionItem Id="pbsiType">
                     <apex:outputLabel value="Type"/>

                        <apex:inputField value="{!opp.Type__c}" id="OppType" onchange="Type('{!$Component.OppType}');">
                             <apex:actionSupport event="onchange" reRender="pbsiType" />


and here is the javascript function I am calling from within.

function Type(Receivetype){
        SelectedType = document.getElementById(Receivetype).value;

Change your ActionSupport to:

<apex:actionSupport event="onchange" onsubmit="Type('{!$Component.OppType}');" reRender="pbsiType" /> 

and remove the onchange event from the element

  • I cant have that on submit as that also require on onchange event – Ricky Nov 19 '15 at 20:41
  • Ricky, onsubmit will not launch on submit of the form, it will do onsubmit of the "actionsupport". This means that your JS code will run, and then the re-render is going to happen – Sebastian Kessel Nov 19 '15 at 20:43

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.