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
prasad1.3969574005596787E12prasad1.3969574005596787E12 

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
Pablo_RoldanPablo_Roldan
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:actionFunction>
<apex:selectList value="{!listValueSelected}" onChange="actionFunctionChangeRepeat(this.options[this.selectedIndex].value);">
<apex:selectOptions value="{!listOptions}"/>
</apex:selectList>
<apex:outputPanel id="panelIteration>
<apex:repeat value="{!listOfIteration}" var="IterationNumber">
<apex:outputText value="IterationNumber"/>
</apex:repeat>
</apex:outputPanel>



public String listValueSelected { get; set; }
public SelectOption[] getListOptions {
SelectOption[] mySO = new SelectOption[]{};
......
return my SO;
}
public String[] listOfIteration {
get{
String[] myLOI = new String[]{};
.....
return myLOI;
}set;
}
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++){
listOfIteration.add(string.valueof(i));
}
}

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