美好的一天, 我在bootstrap popup模式中的代码有问题,当我点击提交按钮/(打印)按钮时它会提前关闭。你会试着告诉我调用弹出模式的正确方法吗? 请参阅下面的代码。感谢帮助:)
<!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="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<!-- Top content -->
<div class="top-content">
<div class="inner-bg">
<div class="container">
<div class="row">
<div class="col-sm-8 col-sm-offset-2 text">
<h1><strong>IT Request </strong> Form</h1>
<div class="description">
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-sm-offset-3 form-box">
<div class="form-bottom">
<form role="form" action="#myModal" method="post" class="login-form">
<div class="form-group">
<label class="sr-only">requestor</label>
<input type="text" name="itrf_requestor" placeholder="Requested By..." class="form-username form-control" id="itrf_requestor">
</div>
<button type="submit" class="btn" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Print</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Javascript -->
<script src="assets/js/jquery-1.11.1.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/js/jquery.backstretch.min.js"></script>
<script src="assets/js/scripts.js"></script>
<!--[if lt IE 10]>
<script src="assets/js/placeholder.js"></script>
<![endif]-->
</body>
</html>
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<form method="POST" action="form.php">
<input type="text" name="form" value="ITREQUESTFORM-">
<input type="text" name="itrf_requestor" value="">
<p>
<input type="submit" alt="SUBMIT" name="Submit" value="PRINT" class="submit-text" />
</form>
</div>
</div>
</div>
</div>
答案 0 :(得分:0)
您已将模态按钮类型描述为&#34;提交&#34;而它应该是&#34; Button&#34;
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<!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="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="assets/js/jquery-1.11.1.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/js/jquery.backstretch.min.js"></script>
<script src="assets/js/scripts.js"></script>
<!--[if lt IE 10]>
<script src="assets/js/placeholder.js"></script>
<![endif]-->
</head>
<!-- Top content -->
<div class="top-content">
<div class="inner-bg">
<div class="container">
<div class="row">
<div class="col-sm-8 col-sm-offset-2 text">
<h1><strong>IT Request </strong> Form</h1>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-sm-offset-3 form-box">
<div class="form-bottom">
<form role="form" method="post" class="login-form">
<div class="form-group">
<label class="sr-only">requestor</label>
<input type="text" name="itrf_requestor" placeholder="Requested By..." class="form-username form-control" id="itrf_requestor">
</div>
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Print</button>
</form>
</div>
</div>
</div>
<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">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<form method="POST" action="form.php">
<input type="text" name="form" value="ITREQUESTFORM-">
<input type="text" name="itrf_requestor" value="">
<p>
<input type="submit" alt="SUBMIT" name="Submit" value="PRINT" class="submit-text" />
</p>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</html>
&#13;