Pass the Picklist value in Javascript Onchange using Visualforce page

Visualforce page use the below codes:

<apex:inputField value=”{!Account.Status}”  onchange=”foo(this.id);” id=”AccStatus”/>

Even better approach will be to send current element to JavaScript function rather than passing only id & then finding same element.

<apex:inputField value=”{!Account.Status}”  onchange=”foo(this);” id=”AccStatus”/>

Javascript Function
function foo(data){
alert(“Call came “);//this is displyed
alert(‘********The field value is ********’+data.value);
}

Written by 

Salesforce MVP | Lightning Champion | 17x Salesforce Certified | Application Architect | 7x Trailhead Ranger | Techforce Services | Australia

Leave a Reply

Your email address will not be published. Required fields are marked *

*