SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

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

    alert option value

    hi

    This is my code :

    Code:
    <select onChange(alert(Selected option ID)) >
    <option id="1">One</option>
    <option id="2">Two</option>
    </select>
    How can I alert ID of selected Item ?

  2. #2
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
      
    <select onChange="alert(this.options[this.selectedIndex].id)" >
    <option id="o1">One</option>
    <option id="o2">Two</option>
    </select>
    or
    Code:
      
    <select onChange="alert(this.options[this.selectedIndex].getAttribute('id'))" >
    <option id="o1">One</option>
    <option id="o2">Two</option>
    </select>
    Last edited by muazzez; Apr 16, 2007 at 07:29.


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
  •