How to use apex:repeat in Visualforce Page?

<apex:variable value="{!1}" var="rowNum"/> <!-- autonumber generate-->
<apex:variable value="{!1}" var="rowNumRadioGrp"/>
<apex:repeat value="{!lstqstionDetails}" var="qustionItem" id="repeatId">
<br/>
<tr>
<td>
<apex:outputText styleClass="qustnTable" value="{!FLOOR(rowNum)}"/>.&nbsp;
<apex:outputText styleClass="qustnTable" value="{!qustionItem['questionName']}" /> <br/>
<apex:variable var="rowNum" value="{!rowNum + 1}"/>
</td>
</tr>
<tr>
<td>
<apex:repeat value="{!qustionItem['Choices']}" var="itemChoices">
<input id='id_{!rowNumRadioGrp}' name="{!qustionItem['questionName']}" type="radio" class="radioGrp"
value="{!itemChoices['value']}" onchange="getSelectedRadioGroupValue(event)" />{!itemChoices['label']}
<apex:variable var="rowNumRadioGrp" value="{!rowNumRadioGrp + 1}"/>
<br/>
</apex:repeat>
</td>
</tr>
</apex:repeat>
Output:-

Leave a Reply