0

In Plain Ole' Javascript, do I NEED to use a loop to loop through the radio buttons/checkboxes to see if they are checked or is there a simpler way of doing this?

Howdy_McGee
  • 10,422
  • 29
  • 111
  • 186

1 Answers1

3

Yes. It may be most helpful to...

  • ...have them all contained in one element, so you can traverse through its children
  • ...apply a class name to all of them, to use document.getElementsByClassName
  • ...use document.getElementsByTagName (though, the tag is the input tag, so you may get other elements as well)

However, that is just getting the elements; but as you've stated, you will still need to iterate through each one to do whatever comparison you like. jQuery will allow you to do this kind of thing more easily, but "Plain Ole' Javascript" cannot.

Jon Newmuis
  • 25,722
  • 2
  • 45
  • 57