SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: selected radio

  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2005
    Posts
    527
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    selected radio

    Hello

    I have some radios like this :

    Code:
    <input type="radio" id="1" >a text from db</input>
    <input type="radio" id="3" >a text from db</input>
    <input type="radio" id="4" >a text from db</input>
    id is the id of field from database is it correct ?

    How can find the selected Item by clicking on a button ?
    I dont want submit form .

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,252
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    radio

    The id values should not begin with a digit. To access the value you could try
    HTML Code:
    .....
    var val = document.getElementById('id_val')
    alert(val);
    .....

  3. #3
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    An <input> is an empty element. It should not have anything between its start and end tags and in HTML it shouldn't even have an end tag. (XHTML requires all elements to have an end tag or use empty element syntax.)

    If you want a radio button to act as part of a group, you must give all of them the same name. You can of course give them IDs as well, which must all be different.
    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
  •