SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Reading Radio via getElementById?

    I've got a radio button with id="po3"

    <input type=radio name="product_options[3]" id="po3" value="13" checked>

    This JS generates a "document.getElementById(...).0.checked is null or not an object

    alert (document.getElementById('po3')[0].checked)

    Since the radio name has [3] in it I can't access it via formid.product_options[3][0].checked.

    Help!

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IDs must be unique. document.getElementById() only returns one element.

    Try this.
    Code:
    formid.elements['product_options[3]'][0].checked
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.


Bookmarks

Posting Permissions

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