editable grid in jsp

Ads
 

editable grid in jsp

i want to create editable grid in jsp for invoice so that i can insert multiple product at a same time.how to create that in jsap, plz reply

View Answers

February 11, 2012 at 3:29 PM

We are providing you the code where we have specified only three fields bookid,author and title in the database. Follow these steps to update these fields:

1) Create book.jsp

<%@page import="java.sql.*"%>

<form name=myname method=post action="edit.jsp">
<table border="1">
<tr><td></td>
<td><b><u>bookid</u></b></td>
<td><b><u>Author</u></b></td>
<td><b><u>title</u></b></td>
</tr>
<%try{

Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root", "root");
ResultSet rs = null;
Statement st=null;
st=conn.createStatement();
rs = st.executeQuery("select * from book");
int i=0; while(rs.next()){ %>
<tr><td><input type="checkbox" name="check<%=i%>" value=<%= rs.getString("bookid") %>></td>
<td><%= rs.getString("bookid") %></td>
<td><%= rs.getString("author") %></td>
<td><%= rs.getString("title") %></td>
</tr><%
i++;
}
}catch(SQLException e){ System.out.println(e.getMessage()); } %>
</table>
<input type="submit">
</form>

2) Create edit.jsp

<%@page import="java.sql.*"%>

<%String id[]= new String[10];
for(int i=0;i<10;i++){
id[i]=request.getParameter("check"+i);
out.println(id[i]);
}
%>

<form name=myname method=post action="update.jsp">
<table border="1">
<tr>
<td><b><u>bookid</u></b></td>
<td><b><u>Author</u></b></td>
<td><b><u>title</u></b></td>
</tr>
<%try{

Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root", "root");
ResultSet rs = null;
Statement st=null;
st=conn.createStatement();
for(int a=0;a<10;a++){
rs = st.executeQuery("select * from book where bookid='"+id[a]+"'");
while(rs.next()){ %>
<tr>
<td><input type="text" name="bid" value="<%= rs.getString("bookid") %>"></td>
<td><input type="text" name="auth" value="<%= rs.getString("author") %>"></td>
<td><input type="text" name="tit" value="<%= rs.getString("title") %>"></td>
</tr><%
}
}
}catch(SQLException e){ System.out.println(e.getMessage()); } %>
</table>

<input type="submit">

3)Create update.jsp

<%@page import="java.sql.*"%>
<%
String d[] =request.getParameterValues("bid");
if(d !=null) {
for(int i=0;i<d.length;i++) {
out.println(d[i]);
}
}
String name[] =request.getParameterValues("auth");
if(name !=null) {
for(int i=0;i<name.length;i++) {
out.println(name[i]);
}
}
String title[] =request.getParameterValues("tit");
if(title !=null) {
for(int i=0;i<title.length;i++) {
out.println(title[i]);
}
}
%>
<%
try{
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root", "root");

Statement st=null;
st=conn.createStatement();
for(int a=0;a<10;a++){
String book_id=d[a];
String author=name[a];
String tit=title[a];
st.executeUpdate("update book set author='"+author+"', title='"+tit+"' where bookid='"+book_id+"'");
}
}
catch(Exception e){
e.printStackTrace();
}
%>

Ads









Related Tutorials/Questions & Answers:
editable grid in jsp
editable grid in jsp  i want to create editable grid in jsp for invoice so that i can insert multiple product at a same time.how to create that in jsap, plz reply   We are providing you the code where we have specified
jsp grid
jsp grid  In jsp table example the values are not being accepted the error is that the item tag doesn't accept any attributes
Advertisements
Jsp Grid
Jsp Grid  <p>&lt;%@ page language="java" import="java.util....;"></p> <pre class="prettyprint">&lt;title&gt;My JSP...; --&gt; </code></pre> <p><title>jsp paging example
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...;JSP Reading Text File</title> </head> <body> <...(); } %> </body> </html> this is my jsp code i want to display
Create Data Grid in JSP page
Create Data Grid in JSP page   ... grid that shows data from database table in jsp page. In this jsp code given... this data grid will fetch data and show in a jsp page. We have used database name
display uploaded file option in editable form
display uploaded file option in editable form  how to show the uploaded file in editable mode on the jsp in struts2.0
display uploaded file option in editable form
display uploaded file option in editable form  how to show the uploaded file in editable mode on the jsp in struts2.0
How to make a horizontally Scrollable grid in jsp using div, table, css, javascript?
How to make a horizontally Scrollable grid in jsp using div, table, css, javascript?  In a jsp page InsertUpdate.jsp (say) there is a button Insert... saving data would be viewed in grid in the same page. Now problem is that, I need
Sigma grid -- Ajax-enabled JavaScript grid
Sigma grid -- Ajax-enabled JavaScript grid       Sigma Grid Sigma Grid is a freely open source AJAX editable data grid, written in pure javascript for displaying and inline
Editable Html
Editable Html  i have editable html table with following elements textbox(n),checkbox(n),sno,dropdownlist..this elements are generated in runtime using javascript by taking the row count from user...now the problem, i dont know
editable combobox method selection
editable combobox method selection  how to make an editable combobox that shows nothing initially but as a key is pressed it pops up and selects an item starting with that letter, subsequent keys would keep sorting from the list
how to use an editable combobox
how to use an editable combobox   Hello Everyone!!!!!!!! I have a jcombo box with certain values and i want to use it as an editable that means when user will type something in combobox, according to that text only matching item
jsp
jsp  hai please give me the table grid code code for jsp
ModuleNotFoundError: No module named 'sphinxcontrib-editable'
ModuleNotFoundError: No module named 'sphinxcontrib-editable'  Hi...: No module named 'sphinxcontrib-editable' How to remove the ModuleNotFoundError: No module named 'sphinxcontrib-editable' error? Thanks   Hi
Editable JTree
Editable JTree Nodes        In this section, you will learn  to make JTree editable...: This program constructs a JTree that contains editable nodes. Firstly, it defines
Ajax grid
Ajax grid  Hi, How I can create ajax grid in my program? Thanks
Problem With Combo Box Editable Property
Problem With Combo Box Editable Property  Hi I am new To Flex i had set Combo Box Editable Property as true. But I didn't get the property filtering in the combo box like when you enter text "S" in the combo box then the names
ModuleNotFoundError: No module named 'django-content_editable'
ModuleNotFoundError: No module named 'django-content_editable'  Hi...: No module named 'django-content_editable' How to remove the ModuleNotFoundError: No module named 'django-content_editable' error? Thanks   
HTML GRID
HTML GRID  how to retrieve data from mysql database in grid form using html and servlets? urgent....   import java.io.*; import java.sql....); } out.println("<html><h3>Pagination of JSP page</h3><body><
Nitobi Grid is not working in IE10/IE11
Nitobi Grid is not working in IE10/IE11  Nitobi grid is working in IE8, but not working in IE10/IE11. we are using above two javascript files to open the grid
i want to create invoice report editable. values should be taken from dabase and editable .. help out asap
i want to create invoice report editable. values should be taken from dabase and editable .. help out asap   i want to create invoice report editable. values should be taken from dabase and editable .. help out asap
ModuleNotFoundError: No module named 'grid'
ModuleNotFoundError: No module named 'grid'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'grid' How to remove the ModuleNotFoundError: No module named 'grid' error
i want to create invoice report editable. values should be taken from dabase and editable .. help out asap
i want to create invoice report editable. values should be taken from dabase and editable .. help out asap   i want to create invoice report .. help out asap
How to export grid into excel
How to export grid into excel  Hi, i created a grid panel i have to export it to the excel. please help me by some sample code. thanks in advance. cool day dude
give me a grid example in php
give me a grid example in php  give me easy code example of grid in php like mysql editor
how can i display a editable result of form?
how can i display a editable result of form?  how can i display a editable result of form? i know how to display form result but the result is display on text. i cant modify them. i have a form with hundreds of checkbox. i want
ModuleNotFoundError: No module named 'odoo10-addon-attachment-attach-non-editable'
-editable'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo10-addon-attachment-attach-non-editable...-attachment-attach-non-editable' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'odoo10-addon-account-move-line-tax-editable'
-editable'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo10-addon-account-move-line-tax-editable...-account-move-line-tax-editable' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'odoo10-addon-attachment-attach-non-editable'
-editable'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo10-addon-attachment-attach-non-editable...-attachment-attach-non-editable' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'odoo11-addon-account-move-line-tax-editable'
-editable'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo11-addon-account-move-line-tax-editable...-account-move-line-tax-editable' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'odoo12-addon-account-move-line-tax-editable'
-editable'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo12-addon-account-move-line-tax-editable...-account-move-line-tax-editable' error? Thanks   Hi, In your

Ads