Posted By

pablazo on 11/06/06


Tagged

javascript select combo


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

meth


Comprobar si un combo tiene algún valor seleccionado


 / Published in: JavaScript
 

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <title>Documento sin t&iacute;tulo</title>
  7. </head>
  8. <script>
  9. function prueba(){
  10.  
  11. for (var i = 0; i < document.form.combo.options.length; i++) {
  12. if (document.form.combo.options [i].selected && document.form.combo.options[i].value!='')
  13. document.write( document.form.combo.options[i].value)
  14. }
  15. }
  16. </script>
  17. <body>
  18. <form name="form">
  19. <select name="combo">
  20. <option value=""></option>
  21. <option value="a">a</option>
  22. <option value="b">b</option>
  23. <option value="c">c</option>
  24. </select>
  25. <input type="button" onClick="prueba();">
  26. </form>
  27. </body>
  28. </html>

Report this snippet  

You need to login to post a comment.