我有一个以html格式输出数据的页面,其中包含用于更新日期的表单。
和registration.php
while($row = mysqli_fetch_array($run))
{
$output .= '
<tr>
<td width="70%">'. $row["fullname"].' </td>
**<form action="add_date.php?id='. $row["client_id"].'" method="post">**
<td width="70%">
<input type="text" value="'. $row["pass_date"].'" id="add_date"
name="add_date"/>
</td>
<td><input type="submit" id="'. $row["client_id"].'" name="submit"
class="btn btn-primary btn-xs"/></td>
</form>
</tr> ';
}
还有另一个页面在模态中显示这些数据。
的index.php
<!--client modal -->
<div id="dataModal" class="modal fade paidclient">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal">×</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body paidclient" id="employee_detail">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-
dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
$(document).on('click', '.today_registration', function(){
$.ajax({
url:"registration.php",
method:"POST",
success:function(data){
$('#employee_detail').html(data);
$('#dataModal').modal('show');
$('.modal-title').text("Today Registration");
}
});
});
<!-- client modal-->
主要问题是表格没有提交,按下时什么都不做 提交按钮
答案 0 :(得分:1)
您只需添加按钮
即可while($row = mysqli_fetch_array($run))
{
$output .= '
<tr>
<td width="70%">'. $row["fullname"].' </td>
<!-- add id in form -->
**<form id="addform" action="add_date.php?id='. $row["client_id"].'" method="post">**
<td width="70%">
<input type="text" value="'. $row["pass_date"].'" id="add_date"
name="add_date"/>
</td>
<td><input type="submit" id="'. $row["client_id"].'" name="submit"
class="btn btn-primary btn-xs"/></td>
</form>
</tr> ';
}
<!--client modal -->
<div id="dataModal" class="modal fade paidclient">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal">×</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body paidclient" id="employee_detail">
</div>
<div class="modal-footer">
<!-- add this button -->
<button type="button" id="btnform" class="btn btn-primary" >Submit</button>
<!-- add this button -->
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- add this -->
$(document).on('click', '#btnform', function(){
$('#addform').submit();
});
<!-- add this -->
$(document).on('click', '.today_registration', function(){
$.ajax({
url:"registration.php",
method:"POST",
success:function(data){
$('#employee_detail').html(data);
$('#dataModal').modal('show');
$('.modal-title').text("Today Registration");
}
});
});
<!-- client modal-->