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
BondicloudBondicloud 

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.

 

Eg:

<script>

var options ;

 

</script>

 

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 ......is it posible?
<apex:actionSupport event="onchange" action="{!viewAccount}" status="akaStatus" rerender="linkPanel"/>
</apex:selectList>

 

can any body help in this ,

 

 

 

Thanks@regards.

Bondi.

sfdcfoxsfdcfox

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

 

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

 

BondicloudBondicloud

HI wrote like this

 

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



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

       </script>

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

 

Thanks for reply.

 

Bondi

 

 

sfdcfoxsfdcfox

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 );
}