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
Sravanthi GSravanthi G 

how to get selected value from the picklist using javascript from visualforce page

how to get selected value from the picklist using javascript from visualforce page
RD@SFRD@SF
Hi Sravanthi,

If you want the current value stored in the database, use ajax request to query using the current id or if you want the current value selected but not saved yet, use the element id by inspecting the field value not the most recommended way. Java script functions can be used in action function and using this you can pass the current object variable as 

{!object.picklistfieldvalue} in the params of the action function and continue what you want to do.

Hope it helps
RD
Thiruchuri AdityanThiruchuri Adityan
For your selectList give the styleclass as pickVal and call the below JS function for onchange..

Ex :<apex:selectList styleClass="pickVal" size="1" onchange="callMe();">

JS Code:

function callMe() {
    var a = document.getElementsByClassName('pickVal')[0].value;
    alert(a);
}
</script>


Try like this..