Share on Google+Share on Google+

Supraja
jsp,javascript
1 Answer(s)      7 years ago
Posted in : JSP-Servlet

Ads

View Answers

May 28, 2009 at 11:08 AM


Hi Friend,

Try the following code.It will retrieve previous and next record from the database to the table.

<%@ page import="java.sql.*" %>
<% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ; %>

<HTML>
<FORM NAME="form1" METHOD="POST">
<%
int current = 0;
if(request.getParameter("hidden") != null) {
current = Integer.parseInt(request.getParameter("hidden"));
}

Connection connection = DriverManager.getConnection("jdbc:odbc:access", "", "");

Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs =
statement.executeQuery("select * from departments");

if(current < 1){
current = 1;
}

rs.last();
int rows = rs.getRow();
if(current <= rows){
rs.absolute(current);
}
%>

<TABLE BORDER="1">
<TR>
<TH>Department Number</TH>
<TH>Department Name</TH>
</TR>
<TR>
<TD><INPUT TYPE ="text" name = "dept" value="<%= rs.getString("dept_Name") %>"/></TD>
<TD><INPUT TYPE ="text" name = "number" value="<%= rs.getString("dept_No") %>"/> </TD>

</TR>
</TABLE>
<BR>
<INPUT TYPE="HIDDEN" NAME="hidden" VALUE="<%= current %>">
<INPUT TYPE="BUTTON" VALUE="Previous Record" ONCLICK="movePrevious()">
<INPUT TYPE="BUTTON" VALUE="Next Record" ONCLICK="moveNext()">
</FORM>

<SCRIPT LANGUAGE="JavaScript">
<!--
function moveNext()
{
var counter = 0
counter = parseInt(document.form1.hidden.value) + 1
document.form1.hidden.value = counter
form1.submit()
}
function movePrevious()
{
var counter = 0
counter = parseInt(document.form1.hidden.value) - 1
document.form1.hidden.value = counter
form1.submit()
}
</SCRIPT>
</HTML>

Thanks









Related Tutorials/Questions & Answers:
jsp /javascript
jsp /javascript  Hii.. I have to design one registration page in java that looks like REGISTER USERNAME (here i have to check whether username already exists in database) EMAIL ADDRESS (here i have to check
jsp /javascript
jsp /javascript  Hii.. I have to design one registration page in java that looks like REGISTER USERNAME (here i have to check whether username already exists in database) EMAIL ADDRESS (here i have to check
Advertisements
how to generate automatic bill based on selected values using jsp/javascript?
how to generate automatic bill based on selected values using jsp/javascript?  how to generate automatic bill based on selected values using jsp/javascript
How to get sub category based on category from database using jsp and javascript.
How to get sub category based on category from database using jsp and javascript.  How to get sub category based on category from database using jsp and javascript
How to make addition of two combobox values using jsp and javascript?
addition of two combobox values using jsp and javascript  How to make addition of two combobox values using jsp and javascript?  <html> <h2>ComboBox</h2> <script language="javascript"> var arr
rtf_jsp_javascript
rtf_jsp_javascript  Hi every one plz give me answer for below question ASAP I created one JSP(used pre defined javascript in jsp to get rtf format in browser) which creats RTF Format in browser to enter data. MY question
jsp or javascript - Java Beginners
jsp or javascript  hello sir can i run sql query in javascript
jsp,javascript - JSP-Servlet
jsp,javascript   Hi, I want to retrieve record and move it. Can any body tell me what is the problem with this code Deparment function update(s) { alert(s); if (s==0) { alert("pr
Servlets,Jsp,Javascript - JSP-Servlet
Servlets,Jsp,Javascript  Hi in my application i am creating a file... ExportToExcel button, jsp Upload plot nos (.xls format). GO Reset ExportToExcel javascript function excelExport() { document.body.style.cursor="wait
Pass value from JSP to JavaScript
Pass value from JSP to JavaScript       We can also pass the value from a JSP page to the java... script from the HTML page. Since in JSP page we can embed HTML tags as well. 
JSP Value to JavaScript
JSP Value to JavaScript          JSP Value to JavaScript tells you to pass the value from JSP to JavaScript. The JavaScript create a function
question
question  how to list images from a file and how to display that images as four different images in each row using jsp / javascript
jsp
jsp  Hi One Help... I want to develop like that using jsp/javascript but nothing is striking in mind... Please give some suggestions to design first Thanks in advance---- Vanchinathan.R
question
question  i used the following code to disable browser back page javascript:window.history.forward(1); but not worked .please give the correct code to disable back page using jsp or javascript
Command Prompt in UI
Command Prompt in UI  Hi One Help... Please go through. I want to develop like that using jsp/javascript but nothing is striking in mind... Please give some suggestions to design first Thanks in advance---- Vanchinathan.R
inbox structure
inbox structure  I want to create an inbox for my project in which records are to be fetched dynamically. I am using netbeans (jsp + javascript+ servlet.) The structure is same like yahoo inbox (1st column full of check boxes
include a jsp file
include a jsp file   Sir, I have 2 jsp pages. I want to include second jsp in the first jsp page when a button in the first jsp is clicked. how can I do this. I tried in sevaral ways . I am using jsp and javascript... anyone
how to get data using dropdownlist, textbox and search button in jsp
how to get data using dropdownlist, textbox and search button in jsp  Hi, I want to display data using jsp,javascript and mysql. My Q. is If i select an entry suppose 'title' from dropdownlist and give a title name 'partial dif
rE - Java Beginners
rE  Hi Friends, use jsp and javascript technologies Add new row created dynamically is successfully..if user fill first row and save this form is successfully but user click add new row button then one row created
jsp drop down without refresh - JSP-Servlet
refresh and what change's is made in jsp of javascript to make proper data...jsp drop down without refresh  Sir I have tried two depenedent jsp dropdown in jsp page,But the probleam is when i select first drop down its
plese send information how to do this - Development process
plese send information how to do this  present i am doing project on javaServlets,jsp,javascript plese see this i have created like subject: button:ok textfield mail: textarea footer
JSP Window. Open
JSP Window. Open          JSP Window. Open  is used to open a new window in JSP. The JavaScript function  window.open( ) open a new browser
JSP - Update displayed content & session variables when user clicks on a button - JSP-Servlet
combination of JSP and javascript would work since my knowledge base is in Java. Here...JSP - Update displayed content & session variables when user clicks... JSP to do some internal check and then increment the value of a number
Java Pass Value Example
;  Pass value from JSP to JavaScript We can also pass the value from a JSP page to the java script as we have done in our... in JSP page we can embed HTML tags as well.    Pass
dynamic drop down
into the designation drop down (use jsp+javascript+servlet) reply soon   1...; <script language="javascript" type="text/javascript">
Javascript - JDBC
and javascript I want to write the event handling code in another jsp page .so... want to use javascript in JSP page so that when click() event will generate...Javascript   Hi, I am doing a project in healthcare domain
Tutorials   
Java Spring Hibernate Struts Training fat image from db fat image from db fat image from db fat image from db unable to get value returned from javascript variable in page How to change image size before adding to mysql using jsp Design a registration.jsp page with input for user registration details Cart Quantity jsp servlet coding issue servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? image pdf marking pdf marking Multiple image upload using JSP Read code from excel sheet and upload into database using JSP Student java about search engine Convert BLOB to PDF and save it to a location how to copy files from remote to local machine using SFTP SSL in java? Like Team viewer Socket and Servert -Jsp how to copy files from remote location to local using java? How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java how to create SOAP based web service in java? how to fetch data from mysql database table and draw a bar chart on that data using in jsp how to create users in LDAP using java? how to authenticate user using TIVOLI api in java? how to create users using IBM Tivoi API in jsp/servelet? Java/J2ee Please explain this code as many packages and classes are unknown to me .! how to download the uploaded folder files using jsp Login Query image is display from path of mysql database please reply the code to store dynamic fields in database? Reloading issue in jsp How to get Button Id ? calling one jap page from another jsp page login login Problem to get connection from DAO class to JDBC Page Loading Time Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below Sending hidden values

Ads

 
Advertisement null

Ads