如何使用模态开始按钮提交表单?

时间:2016-07-07 21:14:11

标签: php bootstrap-modal

使用PHP,我尝试使用bootstrap模式来预览表单帖子。

<!doctype html>
<html>
<head>
    <title>Admin Dashboard</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php include('config/css.php'); ?> <!-- including bootstrap css cdn links -->
    <?php include('config/js.php'); ?>   <!-- including jquery cdn links -->     
</head>

<body>

<div class="container">

<table width="75%" align="center" class="table">
  <tbody>    
<tr>
  <td width="10%" align="left"><label>Item Name</label></td>          

  <td width="35%">
      <form method="POST" name="submit">
      <input type="text" class="form-control" name="itemname" id="itemname" placeholder="Type Item Name"></form>
  </td>      

  <td width="10%" align="left"><label>Item Description</label></td>          

  <td width="35%">
      <form method="POST" name="submit">
      <input type="text" class="form-control" name="itemdes" id="itemdes" placeholder="Type Item Description"></form>
  </td> 

</tr>
  </tbody>
</table>

<input data-toggle="modal" data-target=".previewModal" class="btn btn-success" value="Create Preview"> <!-- Modal Start Button -->

<div class="modal fade previewModal">  <!-- Starting Modal -->
<div class="modal-dialog modal-lg">

<div class="modal-content">        
    <div class="modal-header">Item Name Will be Here</div>       
    <div class="modal-body">Item Description Will be Here</div>             
    <div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">Close</button></div>
</div>

</div>
</div> <!-- End Modal -->

</body>
</html>

现在它只有一个弹出模态窗口的按钮。如何在没有其他按钮的情况下在预览模式中提交表单元素?

1 个答案:

答案 0 :(得分:0)

使用jquery

$(document).ready(function(){

    $("button").click(function(){
    $("form").submit(); 
    });

});
相关问题