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
Priyanka Reddy 74Priyanka Reddy 74 

How to pass ID for radio button dynamically in iteration.

Hi,

I want to pass id for radio button dynamically in iteration, can some one suggest how to do that.

<apex:repeat value="{!am.names}" var="n"> 
<td> 
<input type="radio" name="radio1" id="{!n}"  value="{!n}" onclick="test()"/> 
{!n}      
</td>
</apex:repeat>

Thank you.
Priyanka
RituSharmaRituSharma
You may try like below:
<div id="{!a.Id}"">
.......
</div>
Priyanka Reddy 74Priyanka Reddy 74

Hi Ritu Sharma,

Could you please eloborate.

Thank you.

RituSharmaRituSharma
You may put your input tag inside the div and give dynamic id to the div. Then using JS you may get the input value. Refer below code:

<div id="{!a.Id}"">
<apex:inputCheckBox value="{!a.field_name__c}" />
</div>

Then with javascript something like..
var anchor = document.getElementById("{!a.Id}").firstChild;

// Needed as often the first child is a reference to a text block
while (anchor != null && anchor.nodeType == 3) {
anchor = anchor.nextSibling;
}

// Do something here..
anchor.checked = true;
 
Priyanka Reddy 74Priyanka Reddy 74
Thank you, I'll try this.