从下拉选项重定向到 url 的问题(第二部分)

issue with redirect to url from dropdown options (for second part)

下面我粘贴select表格:

<!-- 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" class="btn btn-light" 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" class="btn btn-light" value="Zainstaluj" /><br>
 </form>
</div>

对于下面的第 1 部分和第 2 部分,我尝试添加脚本:

<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>

第 1 部分工作正确并重定向到 url。但是第 2 部分不起作用:在浏览器中创建 link 看起来像:

?servers=https%3A%2F%2Fmywebsite.com%2Fapp%2Findex.php%3Frp%3D%2Fstore%2Fprestashop-ecommerce%2Fprestashop-ecommerce-own-template&submit=Zainstaluj#popup1

您在第二部分中使用了相同的“id”(html) id="comment-form1",您应该将其更改为 id="comment-form2"