Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title></title>
  4. <script type="text/javascript">
  5.  
  6. let valuesCombo =[["Ensalada", "Provoleta", "Empanadas"],
  7. ["Pizza", "Ravioles", "Bife con fritas"],
  8. ["Flan", "Ensalada de Frutas", "Helado"]]
  9. let select = document.getElementById("selectPlatos");
  10. let selectRng = document.getElementById("selectRng");
  11.  
  12. selectRng.style.display = 'none'
  13.  
  14. select.addEventListener("change", function() {
  15. selectRng.style.display = 'block'
  16.  
  17. agregarCombo(valuesCombo[this.selectedIndex])
  18.  
  19. selectRng.removeAll()
  20. });
  21.  
  22. function agregarCombo(values){
  23.  
  24. while (selectRng.firstChild) {
  25. selectRng.removeChild(selectRng.firstChild);
  26. }
  27.  
  28. for (var i = 0; i < values.length; i++) {
  29. var option = document.createElement("option")
  30. option.value = values[i].toLowerCase();
  31. option.innerHTML = values[i];
  32.  
  33. selectRng.append(option);
  34. }
  35. }
  36.  
  37. </script>
  38. </head>
  39. <body id="body">
  40. <form id="formulario">
  41. <select id="selectPlatos">
  42. <option value="0">Entrada</option>
  43. <option value="1">Plato Principal</option>
  44. <option value="2">Postre</option>
  45. </select>
  46. <select id="selectRng">
  47. </select>
  48. <div>
  49.  
  50. </div>
  51. </form>
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement