PDA

View Full Version : Two "NewBie" questions...



jPaul
Oct 6th, 2005, 05:27 PM
Hello,

First question:
Can I "mix" ASP and Javascript code?
I have ASP code that will fill a recordset from an Access *mdb. I want to display the individual records one at a time.
It seems to me that once I have the recordset on the client I shouldn't have to go back to the server for MoveFirst, MoveNext, MovePrevious, MoveLast or even Quit type of commands.
Does Javascript have recordset handling capabilities, and where can I find out how to use them?


Last question:
I want to display each of these records, one at a time like I mentioned. So I would like to make a javascript function [ myDisplay(A,B,C,D,E,F) ] where the "A" variable is the contents of one field in the record. A=rsRecordSet("fieldname")
I assume a table structure would be the best way to display the info:
How would I display in a table structure through Javascript?
This code doesn't appear to work:


Function myDisplay(A,B,C,D,E,F)
{
document.write("<TABLE WIDTH='100%'><TR><TD></TD>");
document.write("<TD VALIGN=TOP><TABLE><TR><TD COLSPAN=2
ALIGN=TOP ALIGN=CENTER>");
document.write("<FONT COLOR=RED SIZE=+3
FACE=ARIAL></FONT></TD>");
document.write("</TR><TR><TD WIDTH=25% ALIGN=RIGHT
VALIGN=TOP><FONT SIZE=+1 COLOR=BLUE FACE=ARIAL>");
... more statements
}


If someone can help, I appreciate it. I have no idea how to resolve this.

Thanks,
-Paul-

nikkiH
Oct 6th, 2005, 08:32 PM
Hello,

First question:
Can I "mix" ASP and Javascript code?
I have ASP code that will fill a recordset from an Access *mdb. I want to display the individual records one at a time.
It seems to me that once I have the recordset on the client I shouldn't have to go back to the server for MoveFirst, MoveNext, MovePrevious, MoveLast or even Quit type of commands.


No.
It runs on the client.
ASP runs on the server.
By the time the ASP is done, the recordset closes and the page is served out.

ASP.NET can do datagrids, paging, and master/detail.
Either use that, or look at it and how it does it to see how to emulate it in classic ASP.
Still requires a trip to the server to read records.
You can store the data in a javascript array (note: an array, not a recordset, so no writing back to the DB with it) to fudge it with Classic ASP.
ASP.NET stores it client-side as well, just all hashed up in ViewState and session data.

GJay
Oct 6th, 2005, 11:26 PM
You could do it using the xmlHttpRequest features (AJAX), but it's not exactly trivial.
If I were doing it, I would load into the page the current 'thing' (duh...) and then the ones that would be loaded via next/previous/first/last, as appropriate in some kind of cache, so that clicking 'next' (say) loads the next record instantly, while (asynchronously...) the javascript is caching the new next/previous/first/last.

openrico have made a thing they call a 'Live Grid' that does a similar kind of thing, but with scrolling rather than paging, I'm not aware of anything that does exactly what you want...