SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: radio button

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    radio button

    Why the below radio button does give the alert(...) when running it? what's wrong.
    Code:
    <script type="text/javascript">
    for (i=0;i<document.forms.radios.length;i++) 
    {
    	if (document.forms.radios[i].checked==true) {
    		alert(document.forms.radios[i].value);
    	}
    }
    </script>
    <form name="forms" method="post" action="">
      <p>
        <label>
        <input type="radio" name="radios" value="a" checked>
        A</label>
        <br>
        <label>
        <input type="radio" name="radios" value="b">
        B</label>
        <br>
      </p>
    </form>
    <p>&nbsp;</p>
    </body>
    </html>
    Last edited by stymiee; Jul 16, 2007 at 09:35. Reason: added code tags


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
  •