Home Answers Viewqa JSP-Servlet data grid with edit and delete options at each row.

 
 


nataraju
data grid with edit and delete options at each row.
6 Answer(s)      2 years ago
Posted in : JSP-Servlet

i want to display the table data in the format of data grid with edit and delete options at each row. i need it very urgently. advance thanks .

View Answers

May 10, 2011 at 5:15 PM


We are proving you an application.

1)application.jsp:

<%@ page import="java.sql.*" %>
<html>
<head>
<script language="javascript">
function editRecord(id){
    var f=document.form;
    f.method="post";
    f.action='edit.jsp?id='+id;
    f.submit();
}
function deleteRecord(id){
    var f=document.form;
    f.method="post";
    f.action='delete.jsp?id='+id;
    f.submit();
}
</script>
</head>
<body>

<br><br>
<form method="post" name="form">
<table border="1">
<tr><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th></tr>
<%
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "test";
String driver = "com.mysql.jdbc.Driver";
String userName ="root";
String password="root";

int sumcount=0;
Statement st;
try{
Class.forName(driver).newInstance();
con = DriverManager.getConnection(url+db,userName,password);
String query = "select * from employee";
st = con.createStatement();
ResultSet rs = st.executeQuery(query);
%>
<%
while(rs.next()){
%>
<tr><td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
<td><%=rs.getString(4)%></td>
<td><%=rs.getString(5)%></td>
<td><input type="button" name="edit" value="Edit" style="background-color:green;font-weight:bold;color:white;" onclick="editRecord(<%=rs.getString(1)%>);" ></td>
<td><input type="button" name="delete" value="Delete" style="background-color:red;font-weight:bold;color:white;" onclick="deleteRecord(<%=rs.getString(1)%>);" ></td>
</tr>
<%
}
%>
<%
}
catch(Exception e){
e.printStackTrace();
}
%>
</table>
</form>
</body>
</html>

2)edit.jsp:

<%@page language="java"%>
<%@page import="java.sql.*"%>
<form method="post" action="update.jsp">
<table border="1">
<tr><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th></tr>
<%
String id=request.getParameter("id");
int no=Integer.parseInt(id);
int sumcount=0;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
String query = "select * from employee where id='"+no+"'";
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
while(rs.next()){
%>
<tr>
<td><input type="text" name="name" value="<%=rs.getString("name")%>"></td>
<td><input type="text" name="address" value="<%=rs.getString("address")%>"></td>
<td><input type="text" name="contact" value="<%=rs.getInt("contactNo")%>"></td>
<td><input type="text" name="email" value="<%=rs.getString("email")%>"></td>
<td><input type="hidden" name="id" value="<%=rs.getString(1)%>"></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Update" style="background-color:#49743D;font-weight:bold;color:#ffffff;"></td>
</tr>
<%
}
}
catch(Exception e){}
%>
</table>
</form>

May 10, 2011 at 5:16 PM


3)update.jsp:

<%@page import="java.sql.*"%>
<%
String ide=request.getParameter("id");
int num=Integer.parseInt(ide);
String name=request.getParameter("name");
String address=request.getParameter("address");
int contact=Integer.parseInt(request.getParameter("contact"));
String email=request.getParameter("email");
try{
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root");
Statement st=null;
st=conn.createStatement();
st.executeUpdate("update employee set name='"+name+"',address='"+address+"',contactNo="+contact+",email='"+email+"' where id='"+num+"'");
response.sendRedirect("/examples/jsp/application.jsp");
}
catch(Exception e){
System.out.println(e);
}
%>

4)delete.jsp:

<%@ page import="java.sql.*" %> 
<%
int id = Integer.parseInt(request.getParameter("id"));
try{
           Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           int i=st.executeUpdate("delete from employee where id="+id+"");
           response.sendRedirect("application.jsp");
}
catch (Exception e){
System.out.println(e);
}
%>

May 10, 2011 at 5:47 PM


Thank you very much for your answer.


May 16, 2011 at 12:35 PM


Hi. The code you sent was very useful to me. But if I want to send two values from one page to another page how can i send two values. In

f.action

how can i write another variable.

Please respond quickly if you know the answer.


February 21, 2012 at 11:41 PM


what is the database provided in this. table name and their fields.

please reply quickly, i need is urgently


August 23, 2012 at 11:20 AM


Application is working fine ...

but the movement i click on edit button its not displaying any values .. wat might be the prob .. ?

reply soon









Related Pages:
data grid with edit and delete options at each row.
data grid with edit and delete options at each row.  i want to display the table data in the format of data grid with edit and delete options at each row. i need it very urgently. advance thanks
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name
delete and edit options in struts
delete and edit options in struts   Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...;/action> <!-- end of Edit items --> <!-- Delete Items
delete row
delete row  how to delete row using checkbox and button in php... if(isset($_POST['delete'])) { for($i=0;$i<$row;$i++) { $delete... into the html table. Along each table row there is a checkbox consists of id
Delete and add row from Table View iPhone
Delete and add row from Table View iPhone In this tutorial will learn how to delete and also how to add row into the table view iPhone, with the help of edit... of items (or rows) that may be divided into sections. Each row may display strings
Grid rows delete issue
Grid rows delete issue  I have a grid having rows with Remove button... event of dropdown also,so if we delete middle row and then remove all rows on onchange of dropdown then because of rows indexing issue,they can't get middle row
Update / Edit data
from database and display in the html table. At each row, there is a button which...Update / Edit data  Hello, i want to create a page to edit or update user data in the data base. the thing is, when i click on submit reference
Modifying a single row of database based on selection in jsp
-and-delete-options-at-each-row-.html http://www.roseindia.net/answers/viewqa/JSP... in a row with s3everal columns, each row having a radio button and a value... or delete the selected row and update to database.. Please provide me a solution
Delete and edit data in xml file using JSP
Delete and edit data in xml file using JSP   I want to know how to delete and edit data from an XML file by use of JSP. I have XML file having tasks... in the xml file,I want to delete and edit some tasks using task id then how can i do
Adding button to each row for the table and adding row to another table
Adding button to each row for the table and adding row to another table  Hi I need to add button to each line in the table(Table data is retrived form database) and need to add that column data which we click in the specified
insert , edit , and delete button in one jsp page
insert , edit , and delete button in one jsp page  hello I want to ask about the way of creating a jsp page contains insert , edit , and delete buttons and manipulate data in database directly. any help please or hints
delete
delete  how delete only one row in the database using jsp.database... type="button" name="edit" value="Delete" style="background-color:red;font-weight... = conn.createStatement(); st.executeUpdate("DELETE FROM employee WHERE empid
include a delete option in every row of table in a JSP page
include a delete option in every row of table in a JSP page  I have...; <c:forEach var="data" items="${rs.rows}"> <tr><... on Delete it should delete the particular record from the database and reflect
add row in grid using dojo
add row in grid using dojo  add row in grid using dojo
Hibernate delete a row error - Hibernate
Hibernate delete a row error  Hello, I been try with the hibernate delete example (http://www.roseindia.net/hibernate/hibernate-delete.shtml...(); //======================================= sess = fact.openSession(); String hql = "delete from Contact contact
Edit the record.
that particular record.after editing the data i want to edit another row which is next to previous edited row or edit the previous record of the previously edited... or some email.according to the sorted page we should fetch the data and edit
Grid Problem - Java Beginners
belong to different table.but in main form,all data going in the grid(with join... the text of each fields. plz help me how to join table and stored in grid...Grid Problem  Hi Deepak Plz take seriously I m telling u
jsp :how to edit table of data displayed using jsp when clicked on edit button
code retrieve data from database and display in the html table. At each row...jsp :how to edit table of data displayed using jsp when clicked on edit... the particular edit button, that data will get shown in another page and allow the user
Nitobi Grid V3
Nitobi Grid V3       Display & edit tabular data in various web browsers(IE, Firefox & Netscape) with Ajax-powered Nitobi Grid V3. With minimal coding, Grid delivers responsive
delete record
data into the html table. Along each table row there is a checkbox consists of id of table. When the user selects the particular checkbox, that row will get...delete record  how to delete record using checkbox and button in php
How to delete the row from the Database by using servlet
How to delete the row from the Database by using servlet  Dear Sir/Madam I am trying to delete the one user data in the Oracle SQL server database... then the user data to be delete from the database table. Assume in Database table have
edit data
edit data  sir i want to do edit a particular customers information after he logs in, i am also using sessions. thank you
Add Edit And Delete Employee Information
Add Edit and Delete Employee Information Using Swing  ..., edit and delete the Employee's information from the database using java swing... information into the database. The second tab will edit the Employee's information
insert and delete a row programmatically
insert and delete a row programmatically  How to insert and delete a row programmatically ? (new feature in JDBC 2.0
sqlite database delete row
sqlite database delete row  How to delete row from SQLite Database?    NSString *updateSQL = [NSString stringWithFormat: @"DELETE FROM aListDB WHERE id='%@'",details.ids
data grid - JSP-Servlet
data grid  how can we implement data grid (we have data grid... to implement data grid in jsp Thanks varun kumar  Hi friend, I... information. http://www.roseindia.net/jsp/data-grid.shtml Thanks
delete row using id
delete row using id  package pkg2; import org.hibernate.Query; import... = "delete from Insurance insurance where id = 2"; Query query = sess.createQuery(hql); int row = query.executeUpdate(); if (row == 0
grid view in java - Java Beginners
grid view in java  Is it possible to create dynamic grid view to display data from database. if yes. how ??   Hi Friend, Yes, you... prepareRenderer(TableCellRenderer tcr, int row, int column) { Component
Grid Layout Container in Flex4
are same but each row can have a different height. You can take many cells in a row and each cell can have a Grid container. The default Horizontal and Vertical...Grid Layout Container in Flex4: The Grid Layout Container is a MX container
uitableview manually delete row
uitableview manually delete row  uitableview manually delete row   NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet]; [array removeObjectAtIndex:indexPath.row]; if(![array count]) [indexes addIndex
jsp :how to edit table of data displayed using jsp when clicked on edit button
jsp :how to edit table of data displayed using jsp when clicked on edit button  i have a jsp program which displays data in the form of table ..now i want to delete this information in table when click on delete button and save
Create Delete Trigger in SQL
FOR EACH ROW BEGIN INSERT into stu_log(user_id, description) VALUES... Create Delete Trigger in SQL       Create Delete Trigger in SQL fire this trigger before
delete row from a table in hibernate
delete row from a table in hibernate  is there method to delete row in a table using hibernate like save(-) to insert row
delete multiple row using checkbox
delete multiple row using checkbox  how to delete multiple row in a table which is connected to database using checkbox
delete multiple row using checkbox
delete multiple row using checkbox  how to delete multiple row in a table which is connected to database using checkbox
data grid - JSP-Servlet
data grid  i am trying to do the example in the following link http://www.roseindia.net/jsp/data-grid.shtml but i am not able to find... this example  Hi friend, To visit again http://www.roseindia.net/jsp/data
Create Delete Trigger in SQL
'. delimiter $$ CREATE TRIGGER stu_delete before delete ON stu_table FOR EACH ROW... Create Delete Trigger in SQL       Create Delete Trigger in SQL fire this trigger before
How to delete the row from the Database by using while loop in servlet
How to delete the row from the Database by using while loop in servlet  Dear Sir/Madam, I am trying to delete the one user data in the Oracle SQL... are USERS (Char), PASS (Varchar2) and CODE (Varchar2). I am trying to delete 4th user
Delete a row from database by id
Delete a row from database by id  I m creating a small application...) for "DELETE" AND "UPDATE". On clicking delete which is hyper link that particular row.... So anyone will tell me how to give hyper link to Delete and Update and delete
Insert specific fields into table dynamically for each row.
Insert specific fields into table dynamically for each row.  ... insert there for each row and for each row there is a button "done".if he click on done the values will be inserted into database.Then he enter values for next row
Insert specific fields into table dynamically for each row.
Insert specific fields into table dynamically for each row.  ... insert there for each row and for each row there is a button "done".if he click on done the values will be inserted into database.Then he enter values for next row

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.