drvlf9739 2016-05-29 15:24
浏览 32

bootstrap模式弹出并坚持在那里

I have a table with two rows and each one has button . I want the second button pops up a modal but when I run my code the window modal that is supposed to pop up by me clicking on the "View Cart" button doesn't pop up . instead it's already there when I change my page to the page where i have the "View Cart" button. Can anyone help me to solve this problem?

<table>
  <tr>
     <div class="btn_form" style="length :150px;">
     <form method="post"  action="single.php">
 <input type="image" name="cart" value=<?php echo $array[0]['ProductID']?>image src="img/cart.png height="100px" width="100px" onClick="document.submitForm.hidbrand.value=this.value; document.submitForm.submit();" />
   </form>
   </div>
       </tr>
           <tr>
             <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">View Cart</button>
             <div class="modal-content">
              <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times</button>
          <h4 class="modal-title">Modal Header</h4>
        </div>
        <div class="modal-body">
          <p>Some text in the modal.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
   </tr>
 </table>
  • 写回答

1条回答 默认 最新

  • dongzhuo1498 2016-05-29 15:38
    关注

    Move your modal outside the table, and you forgot to include the first two DIVs that define the modal scaffolding.

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
    <table>
      <tr>
        <div class="btn_form" style="length :150px;">
          <form method="post" action="single.php">
            <input type="image" name="cart" value="<?php echo $array[0]['ProductID']; ?>" src="img/cart.png" height="100px" width="100px" onClick="document.submitForm.hidbrand.value=this.value; document.submitForm.submit();" />
          </form>
        </div>
      </tr>
      <tr>
        <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">View Cart</button>
      </tr>
    </table>
    
    <div id="myModal" class="modal fade" role="dialog">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times</button>
            <h4 class="modal-title">Modal Header</h4>
          </div>
          <div class="modal-body">
            <p>Some text in the modal.</p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          </div>
        </div>
      </div>
    </div>

    References:

    http://www.w3schools.com/bootstrap/bootstrap_modal.asp

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?