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

how to get selectoption values from javascript to vfpage

Hi All,


I have selectoption list  values  in java script . how i can access this values in visualforce page.




var options ;




i want to access options values in 


<apex:selectList value="{!selectedAccount}" size="1" id="akaList" >

<apex:selectOptions value="{!options}" id="akaoptId" /> // here i have to access the java script options values it posible?
<apex:actionSupport event="onchange" action="{!viewAccount}" status="akaStatus" rerender="linkPanel"/>


can any body help in this ,







Should be accessible through {!$Component.akaList}:


var selectElement = document.getElementById( "{!$Component.akaList}" )
// should be HTMLSelect type element; use "options" to get the available options.



HI wrote like this


    // writen by narayan                
        function akaoptions2(){
                    var str ='hellow bos';
 var options = [];
<apex:repeat value="{!akaListOptions}" var="requestsList">

                //var optvalu = document.getElementById('{!$Component.akaFormId.akaoptId}').value;
                //document.getElementById('{!$Component.akaFormId.akaoptId}') =options;
                 window.onload = new function() { akaoptions2(); };


      <table> <tr><td>
                <select >
                     <option > options </option> //here iam not get records (values)


Thanks for reply.






The "select" tag needs an ID. You can then call document.getElementById() to obtain the select list in akaoptions2(); your values would be stored in window.options[]. IMHO, it would be far easier to just use a JSON list directly:


// In your page somewhere...
var options = {!akaListOptions};


// In the controller somewhere
public String getAkaListOptions() {
  return JSON.serialize( akaListOptions );