Below i paste select form:
<!-- PART 1 WORKING -->
<div id="first">
<label for="server-select">Wybierz typ instancji dla WooCommerce:</label>
<form id="comment-form1" name="contact-form1" onsubmit="return mysubmit();">
<select name="servers" id="optionswo">
<option value="">--Please choose an option--</option>
<option value="https://myweb.com/app/index.php?rp=/store/woocommerce-ecommerce/wocommerce-ecommerce-own-template">Instancja z własnym szablonem (darmowa instalacja)</option>
<option value="https://myweb.com/app/index.php?rp=/store/woocommerce-ecommerce/woocommerce-clean-instance">Czysta instancja WooCommerce (Dowolna wersja)</option>
<option value="server3">Gotowy sklep WOS1 Kategoria: Sklep zoologiczny</option>
</select><br /><br />
<input name="submit" type="submit" value="Zainstaluj" /><br>
</form>
</div>
<!-- PART 2 NOWORKING -->
<div id="second" style="display: none;">
<label for="server-select">Wybierz typ instancji dla OpenCart:</label>
<form id="comment-form1" name="contact-form2" onsubmit="return mysubmit();">
<select name="servers" id="optionsoc">
<option value="">--Please choose an option--</option>
<option value="https://myweb.com/app/index.php?rp=/store/opencart-ecommerce/opencart-ecommerce-own-template">Instancja z własnym szablonem (darmowa instalacja)</option>
<option value="https://myweb.com/app/index.php?rp=/store/opencart-ecommerce/opencart-clean-instance">Czysta instancja OpenCart (Dowolna wersja)</option>
</select><br /><br />
<input name="submit2" type="submit" value="Zainstaluj" /><br>
</form>
</div>
For Part1 and Part2 below I try add script:
<script>
document.getElementById('comment-form1').addEventListener('submit',(e)=>{
e.preventDefault();
window.location = (document.getElementById('optionswo').value);
})
</script>
<script>
document.getElementById('comment-form2').addEventListener('submit',(e)=>{
e.preventDefault();
window.location = (document.getElementById('optionsoc').value);
})
</script>
And part 1 working correct and redirect to url. But part 2 not working: created link in browser looks like:
?servers=https://mywebsite.com/app/index.php?rp=/store/prestashop-ecommerce/prestashop-ecommerce-own-template&submit=Zainstaluj#popup1
CodePudding user response:
You used same "id" in the second part (html) id="comment-form1", you should change it to id="comment-form2"