• kumar_dev
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies

 

Hi everybody,
I am trying to populate selectlist options through onload javascript function, but some how this is not working. I have pasted the code below that iam working on, could any body please suggest any changes to make it working.
I have highlighted the line where iam getting the problem.
<apex:page >
<script> window.onload = list1;
function list1()
{
var list = document.getElementById('{!$Component.listchosen}')
for(var i=0;i<10;i++)
{
list.add(new Option('xxx','xxx'));
}
}
</script>
<apex:outputPanel id="result"> <apex:form >
<b>Please select :</b>
<apex:selectList id="listchosen" multiselect="false" size="1"> </apex:selectList>
</apex:form>
</apex:outputPanel>
</apex:page>

 

Hi everybody,
I am trying to populate selectlist options through onload javascript function, but some how this is not working. I have pasted the code below that iam working on, could any body please suggest any changes to make it working.
<apex:page >
<script> window.onload = list1;
function list1()
{
var list=document.getElementById('listchosen');
for(var i=0;i<10;i++)
list.add(new Option('xxx','xxx'));
}
</script>
<apex:outputPanel id="result"> <apex:form >
<b>Please select :</b>
<apex:selectList id="listchosen" multiselect="false" size="1"> </apex:selectList>
</apex:form>
</apex:outputPanel>
</apex:page>

 

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.

 

 

Controller:
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<50;i++)
  {
 testList.add('Testing'+i);
  }
Iterations=testList.size();
 }
public void validating()
{
system.debug('select list number' +optionNumber);
options=testList.get(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;
passingSelectedValue(optionNumber);
list.add(new Option('{!options}','{!options}'));
 }
}
</script>
<apex:form >
 <apex:actionFunction name="passingSelectedValue" action="{!validating}" reRender="test"  >
    <apex:param name="optionNumber" assignTo="{!optionNumber}" value="" />
</apex:actionFunction>
<apex:outputPanel id="test">
    <apex:outputtext value="{!options}" id="idSearchGeneric"/>
</apex:outputPanel>
<select id="list" size="1" value="{!selectedValue}" >
<option value=''>--None--</option>
 </select>
 
</apex:form>
</apex:page>

 

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.

 

 

Controller:
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++)
  {
 testList.add('Testing'+i);
  }
Iterations=testList.size();
 }
public void validating()
{
system.debug('select list number' +optionNumber);
options=testList.get(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;
passingSelectedValue(optionNumber);
list.add(new Option('{!options}','{!options}'));
 }
}
</script>
<apex:form >
 <apex:actionFunction name="passingSelectedValue" action="{!validating}" reRender="test"  >
    <apex:param name="optionNumber" assignTo="{!optionNumber}" value="" />
</apex:actionFunction>
<apex:outputPanel id="test">
    <apex:outputtext value="{!options}" id="idSearchGeneric"/>
</apex:outputPanel>
<select id="list" size="1" value="{!selectedValue}" >
<option value=''>--None--</option>
 </select>
 
</apex:form>
</apex:page>

 

 

Thank you.

 

Hi everybody,
I am trying to populate selectlist options through onload javascript function, but some how this is not working. I have pasted the code below that iam working on, could any body please suggest any changes to make it working.
I have highlighted the line where iam getting the problem.
<apex:page >
<script> window.onload = list1;
function list1()
{
var list = document.getElementById('{!$Component.listchosen}')
for(var i=0;i<10;i++)
{
list.add(new Option('xxx','xxx'));
}
}
</script>
<apex:outputPanel id="result"> <apex:form >
<b>Please select :</b>
<apex:selectList id="listchosen" multiselect="false" size="1"> </apex:selectList>
</apex:form>
</apex:outputPanel>
</apex:page>

 

Hi everybody,
I am trying to populate selectlist options through onload javascript function, but some how this is not working. I have pasted the code below that iam working on, could any body please suggest any changes to make it working.
<apex:page >
<script> window.onload = list1;
function list1()
{
var list=document.getElementById('listchosen');
for(var i=0;i<10;i++)
list.add(new Option('xxx','xxx'));
}
</script>
<apex:outputPanel id="result"> <apex:form >
<b>Please select :</b>
<apex:selectList id="listchosen" multiselect="false" size="1"> </apex:selectList>
</apex:form>
</apex:outputPanel>
</apex:page>

 

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.

 

 

Controller:
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++)
  {
 testList.add('Testing'+i);
  }
Iterations=testList.size();
 }
public void validating()
{
system.debug('select list number' +optionNumber);
options=testList.get(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;
passingSelectedValue(optionNumber);
list.add(new Option('{!options}','{!options}'));
 }
}
</script>
<apex:form >
 <apex:actionFunction name="passingSelectedValue" action="{!validating}" reRender="test"  >
    <apex:param name="optionNumber" assignTo="{!optionNumber}" value="" />
</apex:actionFunction>
<apex:outputPanel id="test">
    <apex:outputtext value="{!options}" id="idSearchGeneric"/>
</apex:outputPanel>
<select id="list" size="1" value="{!selectedValue}" >
<option value=''>--None--</option>
 </select>
 
</apex:form>
</apex:page>

 

 

Thank you.