使用引导模式形式的ADD不起作用
ADD using Bootstrap Modal form is not working
我想使用模式表单来填充我的当前表,但它不起作用。我只是需要一些帮助,我可能错过了什么。谢谢
这是我的按钮代码:
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addModal" href="add_dept.php">+ Add Department</button>
以下是我在文件底部的代码,用于显示模式内容:
<div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
</div>
</div>
这是我的add_dept.php代码:
<?php include("../includes/config.php");
$reqErr = "";
if($_SERVER['REQUEST_METHOD'] == "POST") {
if(!empty($_POST['dept_name']) && !empty($_POST['dept_code'])) {
$dept_name = $_POST['dept_name'];
$dept_code = $_POST['dept_code'];
$query_addDept = "INSERT INTO department(dept_name,dept_code) VALUES('$dept_name','$dept_code')";
if(mysqli_query($con,$query_addDept)) {
$reqErr = '<div class="alert alert-success" id="myAlert">
<a href="" class="close"> <i class="fa fa-times"></i></a>
<i class="fa fa-check-circle"></i> Department added</div>';
mysqli_close($con);
}
else {
$reqErr = '<div class="alert alert-danger" id="myAlert">
<a href="" class="close"> <i class="fa fa-times"></i></a>
<i class="fa fa-exclamation-circle"></i> Failed to add Department</div>';
}
}
}
?>
<?php echo $reqErr; ?>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add Department</h4>
</div>
<div class="modal-body">
<form method="POST" class="form" id="add-department" role="form">
<div class="form-group">
<input type="text" class="form-control" id="dept_name" name="dept_name" placeholder="Department Name" />
<span class="help-block"></span>
</div>
<div class="form-group">
<input type="text" class="form-control" id="dept_code" name="dept_code" placeholder="Department Code" />
<span class="help-block"></span>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<input type="submit" id="submit_btn" class="btn btn-primary" />
</div>
</form>
</div>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addModal" href="add_dept.php">+ Add Department</button>
删除href="
<div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<?php require_once('add_dept.php'); ?>
</div>
</div>
</div>
添加最后一个关闭的div
data-target="#addModal" href="add_dept.php"
你的问题就在这里。
您不能将按钮设置为模型触发器和创建页面的链接。
您可以触发模态,在再次单击模态后,重定向到您的add_dept.php页面,或者只在单击时重定向,而不使用模态。
相关文章:
- electronic BrowserWindow的最小高度和宽度在hide()show()方法之后不起作用
- 监视函数从服务返回不起作用,但作用域函数起作用
- 幻灯片滚动javascript不起作用
- 简单的javascript在Shopify中不起作用
- Recaptcha在IE7和IE8中不起作用
- Ember Data DS.Model's set函数不起作用
- JsFiddle上的鼠标事件不起作用
- 我的AngularJS表达式没有'不起作用
- 点击按钮输入不起作用
- 面向对象的Javascript代码在IE7中不起作用
- 分部隐藏在jquery中不起作用
- 在phonegap应用程序内部重定向不起作用
- Javascript add class 不起作用
- 使用引导模式形式的ADD不起作用
- 简单的jquery+javascript不起作用:add".有错误”;不工作,并且未定义onclick事件
- Jquery add/removeClass不起作用
- 在jquery中,react中的Add to link to URL不起作用
- 解析JS SDK: relation.add()不起作用
- onsuccess和oncomplete回调对indexedDb add事务不起作用
- jQuery Add Class没有'不起作用