i'm trying to get the value of radio button placed inside apex repeat. But I could not get the value. Since it is dynamically generating the Ids. I know we can the $ component to get the id,But I believe it will add somenumbers like 0,1,2,3 to the id to make it unique. How to overcome this issue.

  • more details are needed here -- if using a VF controller inner class, the controller object will be bound to the row in the repeat and have access to the radio button value – cropredy Jun 8 '16 at 6:38
  • Sorry Cropredy.I'm unable to understand. But in my VF page I have given the id value to all my components. After clicking the inspect element in the browser I see the following Ids with difference by appending 0 for first option and 1 for 2nd option and so on. how to get the value of the radio button using $component? – prasanthcheenu Jun 8 '16 at 6:55
  • 2
    in a repeat, you can't directly without using, for example, jQuery iterating over DOM elements that end in the id field you set; see blog for one of many examples – cropredy Jun 8 '16 at 7:05
  • Can you please post your VF and controller code snipet? – Saroj Bera Jun 8 '16 at 7:25

You can use the following snippet

function btnclick(e) {
    var currentRow = $(e).closest('tr');

to get the row Id of each row in the apex repeat. You should pass 'this' on click of the radio button to above function.

Let me know if you need more inputs here!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.