Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

Have Programming Question? Ask it here!
 
 
 


nataraju
data grid with edit and delete options at each row.
6 Answer(s)      3 years and 3 months 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 .


Advertisement
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 Tutorials/Questions & Answers:
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
Advertisements
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 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
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
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
add row in grid using dojo
add row in grid using dojo  add row in grid using dojo
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
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
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
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
importing data and edit that data
importing data and edit that data   hello sir i have data in excel sheet which contain 2 rows and i want to import that data to ms access and edit that data like adding new columns and new rows and creating new tables
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
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
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
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
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
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
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
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
how to delete a row in sql without using delete command.
how to delete a row in sql without using delete command.  how to delete a row in sql without using delete command. thanks in advance
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
delete multiple row using checkbox
delete multiple row using checkbox  delete multiple row using checkbox   We are providing you the code where we have specified only three...; st=conn.createStatement(); for(int a=0;a<10;a++){ st.executeUpdate("delete
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
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
delete row from a table using hibernate
delete row from a table using hibernate  //code in java file String hql="delete from CONTACT c where ID=6"; Query query=session.createQuery... [delete from CONTACT] int i=query.executeUpdate
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 data in database
insert and delete data in database  insert and delete data in database from servlets through JDBC   Hi Friend, Please visit the following links: Insert Data Delete Data Thanks
create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?
create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?  I have a project ie create an application for users to create,edit and delete tasks: taskid, taskname, date, project in JSP and struts
create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?
create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?  I have a project ie create an application for users to create,edit and delete tasks: taskid, taskname, date, project in JSP and struts
getting radio button at start of each row of table - Struts
getting radio button at start of each row of table  i have done the following things, and this is fine for me. But i want radio button at the place... at the start of each row as u saw in above output. So what should i have to do
how to display data in List Or grid or in table in Jsp
how to display data in List Or grid or in table in Jsp   <%@page import="java.util.Calendar"%> <%@ page import... String P Value in List GIrd or Table please help am able to Print display data
JDBC Delete Row In Table Example
JDBC Delete Row In Table Example : In this tutorial we will learn how delete... or more specific  row delete from table that follow any given condition...; delete row then count deleted row and display output "Deleted specific
updating rows which contains same id, different value for each row
updating rows which contains same id, different value for each row  ... are there with sid 1. I have to update these 4 rows like this first row(having sid 1) with 'lilitha' as a value for name column second row(having sid 1
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
Update delete perticular row from brower on link - Struts
Update delete perticular row from brower on link   how can update and delete perticular row from List of employee in brower format are ramesh... delete when i click on update than that perticular row are display on another
 

 

 

DMCA.com