admin管理员组文章数量:1391976
I have a display page that displays the data in a particular table. I'm displaying the data in a table, since i'm not displaying all the fields in the table I want to display a detailed version of that field in a pop-up box called modal in bootstrap twitter.
The snapshots of the display page are given below.
To display the values in this pop-up I have to be able to access the id value inside the pop-up. My code for my page is given below.
<%@page import="Product.Op_Product"%>
<%@page import="Common.general"%>
<%@page import="Category.Op_Category" %>
<%@page import="java.sql.ResultSet" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<jsp:include page="Headj.jsp"/>
<body>
<script type="text/javascript">
function deletedata(scatid) {
var url = "Con_Category?action=deletescat&scatid=" + scatid;
window.location = url;
}
</script>
<div id="maindiv" class="container-fluid">
<jsp:include page="Headerj.jsp"/>
<div id="menu_content">
<jsp:include page="Menuj.jsp"/>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<h1 class="page-header">Product</h1>
<ul class="nav nav-tabs" role="tablist">
<li class="active"><a href="#">Display</a></li>
<li><a href="Insertprd.jsp?pg=prd">Add New</a></li>
<!--<li><a href="#">Messages<a><li>-->
</ul>
<br><br>
<div class="alert-success"><p>${param.message}</p></div>
<%
general gen = new general();
Op_Product opp = new Op_Product();
Op_Category opc = new Op_Category();
ResultSet rs = opp.getallproducts();
%>
<table class="table">
<thead>
<th><strong>Sl. No.</strong></th>
<th><strong>Unique ID</strong></th>
<th><strong>Product</strong></th>
<th><strong>Category</strong></th>
<th><strong>Sub-Category</strong></th>
<th><strong>Creator</strong></th>
<th><strong>Operations</strong></th>
</thead>
<%
int no = 1;
while (rs.next()) {
%>
<tr>
<td><%= no%></td>
<td><%= rs.getString("prdf1")%></td>
<td><%= rs.getString("prdf2")%></td>
<td><%= opc.getOnecategoryname(rs.getString("prdf3"))%></td>
<td><%= opc.getOnesubcategoryname(rs.getString("prdf4"))%></td>
<td><%= gen.getCreator(rs.getString("prdf9"))%></td>
<td>
<button type="button" class="btn btn-default btn-sm btn-danger" onclick="deletedata('<%= rs.getString("prdf1")%>');">
<span class="glyphicon glyphicon-trash"></span>
</button>
<button type="button" class="btn btn-default btn-sm btn-primary" onclick="editdata('<%= rs.getString("prdf1")%>')">
<span class="glyphicon glyphicon-edit"></span>
</button>
<button class="btn btn-info btn-sm" data-toggle="modal" data-target="#myModal">
<span class="glyphicon glyphicon-eye-open"></span>
</button>//button to click to display pop-up
</td>
</tr>
<%
no++;
}
%>
</table>
</div>
</div>
</div>
<div>
<jsp:include page="Footerj.jsp"/>
</div>
<!-- Modal -->
<div class="modal " id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
**<!-- Display values here-->**
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
</body>
</html>
Please tell me how to to display the value in the pop-up. I have done this in php symfony using tag inside the modal.
I have a display page that displays the data in a particular table. I'm displaying the data in a table, since i'm not displaying all the fields in the table I want to display a detailed version of that field in a pop-up box called modal in bootstrap twitter.
The snapshots of the display page are given below.
To display the values in this pop-up I have to be able to access the id value inside the pop-up. My code for my page is given below.
<%@page import="Product.Op_Product"%>
<%@page import="Common.general"%>
<%@page import="Category.Op_Category" %>
<%@page import="java.sql.ResultSet" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<jsp:include page="Headj.jsp"/>
<body>
<script type="text/javascript">
function deletedata(scatid) {
var url = "Con_Category?action=deletescat&scatid=" + scatid;
window.location = url;
}
</script>
<div id="maindiv" class="container-fluid">
<jsp:include page="Headerj.jsp"/>
<div id="menu_content">
<jsp:include page="Menuj.jsp"/>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<h1 class="page-header">Product</h1>
<ul class="nav nav-tabs" role="tablist">
<li class="active"><a href="#">Display</a></li>
<li><a href="Insertprd.jsp?pg=prd">Add New</a></li>
<!--<li><a href="#">Messages<a><li>-->
</ul>
<br><br>
<div class="alert-success"><p>${param.message}</p></div>
<%
general gen = new general();
Op_Product opp = new Op_Product();
Op_Category opc = new Op_Category();
ResultSet rs = opp.getallproducts();
%>
<table class="table">
<thead>
<th><strong>Sl. No.</strong></th>
<th><strong>Unique ID</strong></th>
<th><strong>Product</strong></th>
<th><strong>Category</strong></th>
<th><strong>Sub-Category</strong></th>
<th><strong>Creator</strong></th>
<th><strong>Operations</strong></th>
</thead>
<%
int no = 1;
while (rs.next()) {
%>
<tr>
<td><%= no%></td>
<td><%= rs.getString("prdf1")%></td>
<td><%= rs.getString("prdf2")%></td>
<td><%= opc.getOnecategoryname(rs.getString("prdf3"))%></td>
<td><%= opc.getOnesubcategoryname(rs.getString("prdf4"))%></td>
<td><%= gen.getCreator(rs.getString("prdf9"))%></td>
<td>
<button type="button" class="btn btn-default btn-sm btn-danger" onclick="deletedata('<%= rs.getString("prdf1")%>');">
<span class="glyphicon glyphicon-trash"></span>
</button>
<button type="button" class="btn btn-default btn-sm btn-primary" onclick="editdata('<%= rs.getString("prdf1")%>')">
<span class="glyphicon glyphicon-edit"></span>
</button>
<button class="btn btn-info btn-sm" data-toggle="modal" data-target="#myModal">
<span class="glyphicon glyphicon-eye-open"></span>
</button>//button to click to display pop-up
</td>
</tr>
<%
no++;
}
%>
</table>
</div>
</div>
</div>
<div>
<jsp:include page="Footerj.jsp"/>
</div>
<!-- Modal -->
<div class="modal " id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
**<!-- Display values here-->**
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
</body>
</html>
Please tell me how to to display the value in the pop-up. I have done this in php symfony using tag inside the modal.
Share Improve this question asked Jul 25, 2014 at 12:34 ManeshManesh 5963 gold badges15 silver badges31 bronze badges 1- you can load the content corresponding to id using AJAX, Did you tried it? – Navas Basheer Commented Jul 25, 2014 at 17:58
1 Answer
Reset to default 3You can use e.relatedTarget
to find out who invoked the modal. Then use that information during the show.bs.modal
event however you want:
$('#myModal').on('show.bs.modal', function (e) {
$(this).find('.modal-body').html('Fired By: ' + e.relatedTarget.id);
})
Demo in jsFiddle
See also: How to get Twitter Bootstrap Modal's invoker element?
本文标签: javascriptHow to pass a id value to my modal in jspStack Overflow
版权声明:本文标题:javascript - How to pass a id value to my modal in jsp? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744663276a2618376.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论