Spaces:
Sleeping
Sleeping
| <html lang="en" dir="ltr"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Flask Tutorial</title> | |
| </head> | |
| <body> | |
| <button onclick="duplicate()">Forwaaard</button> | |
| <form action="/forward/" method="post"> | |
| <div id ="duplicater"> | |
| <select name="select" class="selections"> | |
| <option value="" disabled selected hidden>Choose value</option> | |
| <option value="hi">hi </option> | |
| <option value="11aaa"> 11</option> | |
| </select> | |
| </div> | |
| <button name="forwardBtn" type="submit">donee</button> | |
| </form> | |
| </body> | |
| </html> | |
| <script > | |
| var i = 0; | |
| var original = document.getElementById('duplicater'); | |
| const vals = []; | |
| function duplicate() { | |
| var clone = original.cloneNode(true); // "deep" clone | |
| // or clone.id = ""; if the divs don't need an ID | |
| clone.id = 'duplicater' + ++i; | |
| clone.getElementsByClassName('selections')[0].setAttribute('name', 'select'+i); | |
| original.parentNode.appendChild(clone); | |
| // var value = clone.id; | |
| console.log( original.parentNode) | |
| console.log( clone ) | |
| var sel0 = document.getElementById('duplicater').getElementsByClassName('selections')[0]; | |
| var sel = document.getElementById(clone.id).getElementsByClassName('selections')[0].tagName; | |
| //var value = sel.textContent[sel.selectedIndex].text; | |
| //var text = sel.options[sel.selectedIndex].text; | |
| //vals.push(text) | |
| console.log(sel0.value) | |
| console.log(sel) | |
| //console.log(value) | |
| //console.log(text) | |
| //var index=original.selectedIndex | |
| //console.log(original.options[index].text) | |
| } | |
| </script> |