Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title></title>
- <script type="text/javascript">
- let valuesCombo =[["Ensalada", "Provoleta", "Empanadas"],
- ["Pizza", "Ravioles", "Bife con fritas"],
- ["Flan", "Ensalada de Frutas", "Helado"]]
- let select = document.getElementById("selectPlatos");
- let selectRng = document.getElementById("selectRng");
- selectRng.style.display = 'none'
- select.addEventListener("change", function() {
- selectRng.style.display = 'block'
- agregarCombo(valuesCombo[this.selectedIndex])
- selectRng.removeAll()
- });
- function agregarCombo(values){
- while (selectRng.firstChild) {
- selectRng.removeChild(selectRng.firstChild);
- }
- for (var i = 0; i < values.length; i++) {
- var option = document.createElement("option")
- option.value = values[i].toLowerCase();
- option.innerHTML = values[i];
- selectRng.append(option);
- }
- }
- </script>
- </head>
- <body id="body">
- <form id="formulario">
- <select id="selectPlatos">
- <option value="0">Entrada</option>
- <option value="1">Plato Principal</option>
- <option value="2">Postre</option>
- </select>
- <select id="selectRng">
- </select>
- <div>
- </div>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement