Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Radio button

 
santhoshK babu
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have more than three hundread radion button in jsf form view . I want to get a value of each radio button in javascript. I tried in this way alert (document.getElementById("radioid").value), but it replays undefined. So please anyone help to resolve this problem.

Thanks,
santhosh.
 
Subrahmanyam Baratam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Try to use this.value when you click the radio button.
 
santhoshK babu
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You are right. But my things is when form is load, on that time i need to get a value of paricular radio button. Please advice for this problem.
 
Bart Kummel
author
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The problem could be that the ID in the (X)HTML page that is generated is not necessarily the same as the ID you gave to the JSF component. That said, some component sets allow you to set a forced ID to be generated in the resulting (X)HTML page. For example Apache MyFaces Tomahawk has "extended components" with a forceId argument. If you're using Tomahawk you could use this feature. Or you could dive into the documentation of the component set that you're using to see if there's a comparable feature. Hope this helps!

Best regards,
Bart Kummel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic