Posted By

stavelin on 02/06/09


Tagged

select jquery drop-down TextField radio-botton


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

luman
umang_nine
benrudolph


Select radiobuttons, textfields and dropdown menys with jquery


 / Published in: jQuery
 

Just so I remember the next time..

  1. Radio button
  2. js:
  3. [$("input[@name='the_name']:checked").val()]
  4.  
  5. html:
  6. <input type="radio" name="the_name" value="0" /> Milk
  7. <input type="radio" name="the_name" value="1" /> Coffie
  8.  
  9. the_name is the name of several buttons, and it's the items value that is selected
  10.  
  11.  
  12. Same method on a textfield:
  13.  
  14. js:
  15. [$('input[@name="newCatField"]').val()]
  16.  
  17. html:
  18. <input type="text" id="newCatField" name="newCatField"/>
  19. same same.
  20.  
  21. On a dropdown menu:
  22.  
  23. js:
  24. $('#myid :selected').val()
  25.  
  26. html:
  27. <select id="myid">
  28. <option value="1">Nyhet</option>
  29. <option value="2">Sport</option>
  30. <option value="3">Utenriks</option>
  31. </select>

Report this snippet  

You need to login to post a comment.