Difference between revisions of "Example datanavigation jssp"
From Lianjapedia
Yvonne.milne (Talk | contribs) |
Yvonne.milne (Talk | contribs) |
||
(14 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | <code lang=" | + | ==Name== |
+ | example_datanavigation.jssp | ||
+ | |||
+ | ==Description== | ||
+ | Example JavaScript Server Page (.jssp page) demonstrating basic data navigation. | ||
+ | |||
+ | ==Code== | ||
+ | |||
+ | <code lang="javascript"> | ||
<%@ Language=JavaScript %> | <%@ Language=JavaScript %> | ||
<html> | <html> | ||
<body> | <body> | ||
<% | <% | ||
− | // Note that just as in PHP, JavaScript Server Pages can use | + | // Note that just as in PHP, JavaScript Server Pages can use include_once(filename) and include(filename) |
// The path of the filename is relative to the directory containing this script. | // The path of the filename is relative to the directory containing this script. | ||
− | + | include_once("library_example.js"); | |
// The Lianja global object provides embedded database access | // The Lianja global object provides embedded database access | ||
db = Lianja.openDatabase("southwind"); | db = Lianja.openDatabase("southwind"); | ||
− | |||
print("<br>"); | print("<br>"); | ||
// Lianja.openDatabase() returns a Database object so now we can open a RecordSet | // Lianja.openDatabase() returns a Database object so now we can open a RecordSet | ||
rs = db.openRecordSet("select * from customers"); | rs = db.openRecordSet("select * from customers"); | ||
− | |||
print("<br>"); | print("<br>"); | ||
print("Fieldcount="+rs.fieldcount); | print("Fieldcount="+rs.fieldcount); | ||
Line 46: | Line 52: | ||
</html> | </html> | ||
</code> | </code> | ||
− | [[Category: | + | [[Category:JavaScriptCodeExamples]] |
+ | [[Category:JavaScript Scripting]] | ||
+ | [[Category:Working with Data]] |
Latest revision as of 07:49, 22 July 2016
Name
example_datanavigation.jssp
Description
Example JavaScript Server Page (.jssp page) demonstrating basic data navigation.
Code
<%@ Language=JavaScript %> <html> <body> <% // Note that just as in PHP, JavaScript Server Pages can use include_once(filename) and include(filename) // The path of the filename is relative to the directory containing this script. include_once("library_example.js"); // The Lianja global object provides embedded database access db = Lianja.openDatabase("southwind"); print("<br>"); // Lianja.openDatabase() returns a Database object so now we can open a RecordSet rs = db.openRecordSet("select * from customers"); print("<br>"); print("Fieldcount="+rs.fieldcount); print("<br>"); %> <table> <% print("<tr>"); for (i=0; i<rs.fieldcount; ++i) { print("<td>"+rs.field(i).name+"</td>"); } print("</tr>"); rs.moveFirst(); for (j=0; j<rs.reccount; ++j) { print("<tr valign='top'>"); for (i=0; i<rs.fieldcount; ++i) { print("<td>"+rs.field(i).value+"</td>"); } print("</tr>"); rs.moveNext(); } rs.close(); db.close(); %> </table> </body> </html>