+ Start a Discussion

How to control apex:repeat using picklist value

Hi All,

I am trying to iterate the apex:repeat with value of picklist.
what I mean is........... If I select 3 from picklist, apex:repeat must iterate only 3 times only.
Please help me
So if I have understood that, you want to do something like this:
<apex:actionFunction name="actionFunctionChangeRepeat" action="{!apexMethodChangeRepeat}" rerender="panelIteration">
<apex:param name="listValueSelected" value=""/>
<apex:selectList value="{!listValueSelected}" onChange="actionFunctionChangeRepeat(this.options[this.selectedIndex].value);">
<apex:selectOptions value="{!listOptions}"/>
<apex:outputPanel id="panelIteration>
<apex:repeat value="{!listOfIteration}" var="IterationNumber">
<apex:outputText value="IterationNumber"/>

public String listValueSelected { get; set; }
public SelectOption[] getListOptions {
SelectOption[] mySO = new SelectOption[]{};
return my SO;
public String[] listOfIteration {
String[] myLOI = new String[]{};
return myLOI;
public void apexMethodChangeRepeat(){
String myValue = Apexpages.currentPage.getParameters().get('listValueSelected');
listOfIteration = new String[]{};
Integer Total = integer.valueof(myValue);
for(Integer i = 0; i < Total; i++){

I hope that this helps you, please click on "Best answer" in that case.