+ Start a Discussion

Pleasee help, Populating selectlist options using onload javascript function from controller

Hello Friends,

According to my requirment i need to update selectlist with more than 1000 items from controller arraylist,which is not possible in Visuaforce page as we should not exceed more than 1000 at a time, so I am trying to populate selectlist options using  javascript onload function and using apex:actionFunction to invoke a method in controller to update selectoptions ,But somehow the selectlist is not being updated after each iteration in javascript.

Please look at the sample code that i have written and suggest me any changes to make it work.



public class commentsController {
public Integer Iterations{get;set;}
public list<string> testList{get;set;}
public Integer optionNumber{get;set;}
public string options {get;set;}
public string selectedValue{get;set;}
public commentsController(ApexPages.StandardController stdController)
testList= new list<string>(); 
for(integer i=0;i<1050;i++)
public void validating()
system.debug('select list number' +optionNumber);
VF page code:
<apex:page id="commentspage"  standardController="opportunity" extensions="commentsController">
 <script language="Javascript">
 window.onload = CheckCategories;
function CheckCategories() {
var list=document.getElementById('list');
for(var i=0;i<{!Iterations};i++){
var optionNumber=i;
list.add(new Option('{!options}','{!options}'));
<apex:form >
 <apex:actionFunction name="passingSelectedValue" action="{!validating}" reRender="test"  >
    <apex:param name="optionNumber" assignTo="{!optionNumber}" value="" />
<apex:outputPanel id="test">
    <apex:outputtext value="{!options}" id="idSearchGeneric"/>
<select id="list" size="1" value="{!selectedValue}" >
<option value=''>--None--</option>



Thank you.


try and use pagination.


its just i need to update selectlist options from arraylist(which is there in controller) at once before the VF page loaded, So i guess using pagination is not feasible for this scenario. You can try by copy paste the code in your devloper account and you can see selectlist is being updated with null values. 


Thanks for the reply.