2017-03-26 63 views
1

我有以下形式的代碼:爲什麼不正確使用我的模式?

<div class="modal" id="myModal" role="dialog"> 
    <div class="modal-dialog"> 
     <!-- Modal content--> 
     <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> 
    <form action="/admin/menuContent.php?id=<?php echo $menuId ?>" method="post"> 
     //few inputs... 
     <div class="col-sm-1"> 
      <input id="editButton" class="btn btn-success editButton" type="submit" value="Save" data-toggle="modal" data-target="#myModal" role="button"> 
     </div> 
     <div class="col-sm-1"> 
      <a href="/admin/menus.php" class="btn btn-default cancelButton">Cancel</a> 
     </div> 
    </form> 

而我的問題是,點擊保存按鈕後會出現模式,但只是第二或以下,有什麼可以成爲一個問題?感謝您的幫助! :)

回答

0

該錯誤來僅僅是因爲在形式action.try傳遞的URL來弄清楚。是否你傳遞了正確的URL。 我試過這個。

<!DOCTYPE html> 
 
    <html lang="en"> 
 
    <head> 
 
    <title>Bootstrap Example</title> 
 
    <meta charset="utf-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
    <link rel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"> </script> 
 
    </head> 
 
    <body> 
 
    <div class="container"> 
 
    <div class="modal" id="myModal" role="dialog"> 
 
    <div class="modal-dialog"> 
 
     <!-- Modal content--> 
 
     <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> 
 

 
     <div class="col-sm-1"> 
 
      <input id="editButton" class="btn btn-success editButton" type="submit" value="Save" data-toggle="modal" data-target="#myModal" role="button"> 
 
     </div> 
 
     </div> 
 
    
 
    </div> 
 
    </body> 
 
    </html>

0

你不應該觸發表單提交和模式與單提交button.When你觸發了提交按鈕的模態消失,直接到menuContent.php。你應該使用某些客戶端端程序將參數傳遞給php。

相關問題