Results 1 to 3 of 3

Thread: getElementsByTagName to return the id

  1. #1
    Join Date
    Sep 2011

    getElementsByTagName to return the id


    I am using getElementsByTagName('input') and would like to return the id of the radio button that is checked. My script returns: 'undefined'. I was hoping to see the string that I had set for the id property in my HTML.

    Here is what I tried:

    function Test()

    var docButtons=document.getElementsByTagName('input')
    for (var i=0; i<docButtons.length; i++)
    { if (docButtons[i].checked == true) {alert(docButtons.id)} }


    I was leery on 'docButtons.id' but figured I would give it a shot. Will someone please help me out?


  2. #2
    Join Date
    Nov 2010
    untested, but docButtons[i].id should bring better results

  3. #3
    Join Date
    Sep 2011
    Thanks again, xelawho

    I can't believe that I am not catching these things! lol

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles