[英]When i click edit in html table how to send those details same page text boxes to update in jsp
I have jsp page in that I did insert and displaying records in html table in one page only in when i click edit it redirect to update.jsp
page but i need to do same page only without taking another update.jsp
page 我有jsp页面中,我没有插入,只有在当我点击编辑重定向到一个页面显示在HTML表中的记录
update.jsp
页面,但我只需要而无需再次做同样的页面update.jsp
页
Is it possible to do Insert,Update,Delete in single page? 是否可以在单个页面中执行插入,更新,删除?
yes it is possible to edit in same page. 是的,可以在同一页面中进行编辑。
You can use ajax for it. 您可以使用ajax。 form of project insert in jsp using jstl
使用jstl在jsp中插入项目的形式
<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<c:if test="${empty sessionScope['loginUser']}">
<c:redirect url="login.jsp" />
</c:if>
<jsp:include page="header.jsp" />
<!-- Content -->
<!-- Basic inputs -->
<!-- Basic inputs -->
<script src="http://code.jquery.com/jquery-1.10.1.min.js" ></script>
<script>
$(document).ready(function(){
$("form").on('submit',function(event){
event.preventDefault();
var p_title = document.getElementById('p_title').value;
var p_decription = document.getElementById('p_decription').value;
var s_date = document.getElementById('s_date').value;
var e_date = document.getElementById('e_date').value;
var p_language = document.getElementById('p_language').value;
$.ajax({
type: "POST",
url: "insert_project.jsp",
data: {p_title:p_title,p_decription:p_decription,s_date:s_date,e_date:e_date,p_language:p_language},
}).done(function(data){
alert("Data Inserted succesfullly");
});
});
});
</script>
<form action="#">
<div id="main_wrapper">
<div class="container-fluid">
<fieldset>
<legend><span>Add Project Details</span></legend>
</fieldset>
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label class="control-label">Project Title:</label>
<input type="text" name="p_title" id="p_title" class="form-control" />
</div>
<div class="form-group">
<label class="control-label">Project Description:</label>
<input class="form-control" type="text" name="p_decription" id="p_decription" />
</div>
<div class="form-group">
<label class="control-label">Start Date:</label>
<input class="form-control" type="text" name="s_date" id="s_date" />
</div>
<div class="form-group">
<label class="control-label">End Date:</label>
<input class="form-control" type="text" name="e_date" id="e_date" />
</div>
<div class="form-group">
<label class="control-label">Project Language:</label>
<input class="form-control" type="text" name="p_language" id="p_language" /></div>
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="reset" class="btn">Reset</button>
</div>
</div>
</div>
</form>
<!-- /basic inputs -->
<jsp:include page="sidebar.jsp" />
insert_project.jsp insert_project.jsp
<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<%@include file="connection.jsp"%>
<sql:update dataSource="${snapshot}" var="result">
INSERT INTO project_master(project_title,project_description,project_start_date,project_end_date,project_language) VALUES (?,?,?,?,?);
<sql:param value="${param.p_title}" />
<sql:param value="${param.p_decription}" />
<sql:param value="${param.s_date}" />
<sql:param value="${param.e_date}" />
<sql:param value="${param.p_language}" />
</sql:update>
this is how you can use ajax in jsp. 这就是在jsp中使用ajax的方法。 this is demo of insert you can pass is for update and delete in ajax and make page for it write code for update and delete.
这是插入的演示,您可以通过它在ajax中进行更新和删除,并为其创建页面编写更新和删除代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.