模态表单未显示



我有一个.jsp文件,在该文件上有一个标头,其中包含一个id为"的按钮;modalFormButton";,当按下时必须显示一个模态表单。模态表单的代码在另一个.jsp文件中,所以我正在动态添加它。我已经检查了它是否成功地调用了包含所述内容的文件,但它没有显示表单。我还尝试将表单代码放在我调用它的同一.jsp中,但它也不起作用。

PS:模态形式包含在id为"的div中;agregarClienteMode";。此外,我正在使用Bootstrap。

.jsp主文件:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<title>JSP Page</title>
</head>
<body>
<header class = "py-2 bg-info text-white">
<div>
<h1>
Clients
</h1>
<button type = "button" id = "modalFormButton" class="btn btn-primary btn-block data-toggle="modal" data-target="#agregarClienteModal">
Agregar Cliente
</button>
</div>
<jsp:include page="addClientModalForm.jsp"/>
</header>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
</body>
</html>

模态形式代码:

<div class="modal fade" id="agregarClienteModal">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header bg-info text-white">
<h5 class="modal-title">Agregar Cliente</h5> 
<button class="close" data-dismiss="modal">
<span>&times;</span>
</button>
</div>

<form action="${pageContext.request.contextPath}/servlet?accion=insertar"
method="POST" class="was-validated">

<div class="modal-body">
<div class="form-group">
<label for="nombre">Nombre</label>
<input type="text" class="form-control" name="nombre" required>
</div>
<div class="form-group">
<label for="apellido">Apellido</label>
<input type="text" class="form-control" name="apellido" required>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" name="email" required>
</div>
<div class="form-group">
<label for="telefono">Teléfono</label>
<input type="tel" class="form-control" name="telefono" required>
</div>
<div class="form-group">
<label for="saldo">Saldo</label>
<input type="number" class="form-control" name="saldo" required step="any">
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="submit">Guardar</button>
</div>    
</form>
</div>
</div>
</div>

data-属性在Bootstrap 5…中更改为data-bs-

<div>
<h1> Clients </h1>
<button type="button" id="modalFormButton" class="btn btn-primary btn-block" data-bs-toggle="modal" data-bs-target="#agregarClienteModal"> Agregar Cliente </button>
</div>

演示

相关内容

  • 没有找到相关文章

最新更新