• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Question on dynamically generated radio buttons

 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a JSP page which generates the name of the radio button dynamically.
My code in JSP:

<html:radio property = '<%=question.getOid()%>' value =
"<%=qvalue.getOid()%>" onklick="showRadioLayer(this)"/>

This JSP code generates 2 radio buttons with the same name(radio group) but with different values.

My code in Java Script:

function showRadioLayer(id){
var a = id.name; // I can get the name of the radio button with this
var len = document.form.a.length //I want to get length of radio group
but i cant get the length. I know this is wrong but how do i get the length of the radio group.

Please help me,
Thanks
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
because you are not referecing it right...

var len = document.form.elements[a].length;

Eric
 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot!!!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic