User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 427,812 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,824 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

how to get to next record on click of a button.

Join Date: Jul 2006
Location: Deptford, London
Posts: 964
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 48
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: how to get to next record on click of a button.

  #2  
Mar 13th, 2007
You're trying to directly mix a process across two different environments. It won't work like that.

That page executes twice as two different 'programs' so to speak. Firstly; it's a JSP? program; which is able to connect to your database (on a server) and to 'transform' the page somewhat. After the JSP process has run; your page will look something like this:

<html>
<body>
<script>
function getDetails()
{
rs.next()
}
</script>
<form method="post">
Website:<input type="text" value="example"><br>
Url:<input type="text" value="http://example.com"><br>
Category: <input type="text" value="generic"><br>
Description: <input type="text" value="these values came from your database"><br>
Search Engine-><br>
Yahoo: <input type="text" value="is a search engine"><br>
Google: <input type="text" value="owns the web"><br>
Altavista: <input type="text" value="used to be more popular"><br>
<input type="button" value="Next" onClick="getDetails()">
</form>
</body>
</html>

That page is sent to a web browser; where it is interpretted as an "HTML and Javascript" program. Clearly; there's no reference anywhere to the 'rs' object that you were using at the server; and even if there was; you wouldn't be able to keep a local connection to your database active on a remote machine.

The easiest way you can do what you want to do; is to send information to your server side script by whatever means; telling it which record to display. You could do that by reloading the page with a query string variable when the 'next' button is clicked; and then using that in the JSP program as a record index... Or using an AJAX method to send a request from a Javascript method (running in a user's browser) to a JSP program (running on the server) that replies with raw (indexed) record data; which can then be used to fill in the fields.

Or, if your recordset is always going to be quite small; you could use JSP to write the records into Javascript arrays; and then move through them when 'next' is clicked.

I think, you may get better assistance at the JSP forum. Personally, I have no way to run JSP code; so I can't give you particularly specific advice.
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
All times are GMT -4. The time now is 2:31 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC