Help with Javascript on generated html with no ids

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anokun7
    New Member
    • Jan 2007
    • 1

    Help with Javascript on generated html with no ids

    Hi,

    We have an application that generates html code through a GUI... The html fields (like radio, checkbox etc..) generated are all inside table/tr/td. And none of the fields are assigned any id.

    The issue currently is that we have many radio buttons generated in the same way. They just cannot be grouped. And we need to make sure that the user can select only one at a given time... We think we can use javascript for this.. but since none of the fields have an id we are in a tight spot - Can someone suggest if it is possible to call javascript when there are no field id's or even names? (We tried using getElementById and getElementByNam e - neither give any results - they evaluate to null...

    Thanks,
    A
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    You need to learn the DOM better as it is the only way to do this. I'm too rusty myself to help further than that.

    Comment

    • DeMan
      Top Contributor
      • Nov 2006
      • 1799

      #3
      why can't they be grouped together?

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        There should also be a getelementbytag function.

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          If your boxes have a name, as they should, you can address them using one of the following formats:
          [html]
          //where myform and radioname are names of your form/element.
          document.myform .radioname
          //where i is the position of the radio button within form
          document.myform .elements[i]
          //where i is the position of the radio within a group of radio buttons.
          document.myform .radioname[i] [/html]
          See DOM info at Radio button DOM info

          Ronald

          Comment

          Working...