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
JamalRidaJamalRida 

retrieve picklist value in javascript

Hello, i would like to know how can we retrieve the value of a picklist in javascript please any help  !

KrishSFDCKrishSFDC

Hi,

the below link might help you retrieving picklist values in Javascript:

 

http://www.oyecode.com/2013/06/how-to-javascript-to-get-multi-values.html

 

Thanks

Gopi

DBSync LLC

www.mydbsync.com

Malika Pathak 9Malika Pathak 9

Hi JamalRida,

please find the solution

Define an Id on the tag on your visualforce page:

 

<apex:repeat value="{!myWrapper}" var="wrap">
<tr>

 <td id="SelectedComponent">
 <apex:selectList 
id="selected" value="{!wrap.selected}" size="1"   style="width: 100%;" >

<apex:selectOptions value="{!wrap.SelectList}">
</apex:selectOptions>
  </apex:selectList>
</td>
</tr>
</apex:repeat>
 <apex:commandButton onclick="if(!fncInitiate()){return false};return 
false;" value="Perfios Initiate - Applicant" style="width:19%;color: #0072bc;" reRender=""/>
 


Then get the selected value in the javaScript method through the help of this Id.
JS:

 

function fncInitiate(){
//get the selected value from all the rows here
var selectedValue = $("#SelectedComponent").find(":selected").text();
console.log(selectedValue);
}
 

If you find this solution is helpful for you please mark the best answer