我想在模式弹出窗口中显示具有特定ID的用户。如何将ID发送到模态并将其发送到dao文件,以便我可以从数据库中检索该用户。
将该ID发送给模态后,我想从js获取ID并将其保存到变量中以进行进一步处理。
JavaScript -
$(document).ready(function() {
$('#myinfo').click(function (e)
{
var userId = $(this).data('id');;
$.ajax({
type: "post",
url: "memberlist.jsp", //or whatever your url is
data: "userId=" + userId,
success: function(data){
$(".tables").html(data);
}
});
});
});
查看,编辑和删除按钮-
<button type="button" data-toggle="modal" data-id="<%=bean.getId()%>" data-target="#myinfo" data-uid="1" class="update btn btn-info btn-sm"><span class="glyphicon glyphicon-eye-open"></span></button>
<button type="button" data-toggle="modal" data-id="<%=bean.getId()%>" data-target="#myModalharsha" data-uid="2" class="update btn btn-warning btn-sm"><span class="glyphicon glyphicon-pencil"></span></button>
<button type="button" data-toggle="modal" data-id="<%=bean.getId()%>" data-target="#delete" data-uid="2" class="delete btn btn-danger btn-sm"><span class="glyphicon glyphicon-trash"></span></button></td>
Memberlist.jsp -
<div class="table-responsive bs-example widget-shadow">
<h4>Member Details:</h4>
<input type="text" name="userId" id="userId" value=""/>
<table class="table table-hover">
<%
String id = request.getParameter("userId");
int userId = Integer.parseInt(id);
UserBean bean = UserDao.viewUser(userId);
%>
<tr>
<td><b>Name:</b></td>
<td><%=bean.getName() %></td>
</tr>
<tr>
<td><b>Email ID:</b></td>
<td><%=bean.getEmailId() %></td>
</tr>
<tr>
<td>Mobile:</td>
<td><%=bean.getMobile() %></td>
</tr>
<tr>
<td><b>Business Name:</b></td>
<td><%=bean.getBusinessName() %></td>
</tr>
<tr>
<td><b>Address:</b></td>
<td><%=bean.getAddress() %></td>
</tr>
<tr>
<td><b>Created:</b></td>
<td><%=bean.getCreated() %></td>
</tr>
<tr>
<td><b>User Type:</b></td>
<td><%=bean.getUserType() %></td>
</tr>
<tr>
<td><b>ParentType:</b></td>
<td><%=bean.getParentType() %></td>
</tr>
</table>
</div>
</div>
请帮助我-