doulian8554 2019-07-04 08:06
浏览 227

Bootstrap模态和JS onChange(),有可能吗?

I was thinking of using the bootstrap modal to select category and reorder a list of products.

From a dropdown, I have the list of categories to choose for reordering but using javascript to load the products after choosing the category, the modal window closes. Maybe I want to use the modals in a way that can't be done?

    <div class="modal-body">
       <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="get" name="mdlfrmListProduct" id="frmListProduct"> 
    <div class="tbl-cell tbl-cell-title col-md-5">
         <select name="modalCategory" class="form-control" id="modalCategory" onChange="modalProduct();"
       required />
   <option value="">Select category</option>

 <?php  echo CategoryTree(); ?>  
    </select>
      </div>
        </form>


function modalProduct()
{
    with (window.document.mdlfrmListProduct) {
        if (modalCategory.selectedIndex == 0) {
            window.location.href = 'index.php';
        } else {
            window.location.href = 'index.php?catId=' + modalCategory.options[modalCategory.selectedIndex].value;
        }
    }
}
</script>
        </div>
  • 写回答

1条回答 默认 最新

  • doutanggun9816 2019-07-04 08:18
    关注

    the modal is provided with display:none until its called up.

    When the modal is called and you trigger the onchange function, you reload the page. Of course the modal is no longer called and hidden.

    Since you want to hollow out the changes from the server, it would be a solution to load them from the server via AJAX and then set the values using javascript.

    评论

报告相同问题?

悬赏问题

  • ¥15 BV260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序