selcr tag and DOM

Discussion in 'JavaScript' started by progfrog, Jan 9, 2009.

  1. #1
    Hi!
    can anyone tell me what is wrong with the code?

    It has something to do with the way i call the value of the selected option but i cannot track the problem..

    
    
    
    <html>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1255 ">
    <head>
    <script type="javascript">
    function foo(l,c)
    {
    
    var z=document.getElementById(c) 
     alert(l.z.options[l.z.options.selectedIndex].value) 
    
    }
    
    
    
    
    </script>
    
    
    
    
    </head>
    
    <body>
    <form id="ghost">
    <select name="bery" id="sel" onchange="foo('ghost','sel')">
    <option>1</option>
    <option>2</option>
    </select>
    </body>
    
    </form>
    </html>
    
    
    
    
    
    
    Code (markup):

    thanx!
     
    progfrog, Jan 9, 2009 IP
  2. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
    #2
    just do

    document.getElementById("sel").value;
     
    crath, Jan 9, 2009 IP