views:

30

answers:

1

Hi all

Got a simple question. I would like to get a drop down menu value when a use clicks it. I tried to write the code on my own, but couldn't do it. Any helps would be appreciated.

My Jquery

 $("#week").change(function(){

     var input=$("week: select").val();

     alert(input);  //display undefiend

My Html

   <form id="week">
   <select>
    <option>Week 1</option>
    <option>Week 2</option>
    <option>Week 3</option>
    <option>Week 4</option>
    <option>Week 5</option>

   </select> 
  </form>
+5  A: 

Do this:

$("#week select").change(function(){    
     var input = $(this).val();    
     alert(input);
});
Web Logic
@Kobi - The select is a *child* of `#week`, his code is correct.
Nick Craver
Thanks a lot guys.
Jerry
@Jerry: You are welcome :)
Web Logic