<SERVER>
// This example shows how to create a LassoSession, set it up for a search, then print out the results.
// This example uses the Employees.fp3 FileMaker Pro database which ships with Lasso.
// write out HTML header using a specified title
function header(title)
{
write('<HTML>\
<HEAD>\
<TITLE>', title, '</TITLE>\
</HEAD>\
<BODY BGCOLOR="#FFFFFF">\n');
flush();
}
// write out HTML footer
function footer()
{
write('</BODY>\n</HTML>');
}
// initialize a new session using the specified database, table and action
function initializeSession(theDatabase, theTable, theAction)
{
// create a new session object
var theSession = new LassoSession();
// create a reference to the session's input parameters object
var theInput = theSession.getInputParameters();
// set the database name
theInput.databaseName = theDatabase;
// set the table/layout name
theInput.tableName = theTable;
// set the database action
theInput.action = theAction;
// return the new session
return theSession;
}
// write out the page header
header('JavaScript Example 2');
// did the default session perform any database activity?
if (lasso.defaultSession.getInputParameters().action == 'nothing')
{
// initialize a new session
var mySession = initializeSession('Employees.fp3', 'Web', 'findall');
// set the maximum number of records returned to 10
mySession.getInputParameters().maxRecords = 10;
// execute the session
mySession.execute();
}
else
{
// create a reference to the default session
var mySession = lasso.defaultSession;
}
// was the session executed successfully?
if (mySession.getResultCode() == 0)
{
// create a reference to the session's result set
var mySet = mySession.getResultSet();
// write out the main table's headers
write('<table border=2 cellpadding=2 cellspacing=2>\
<tr>\
<th>ID </th>\
<th>First Name </th>\
<th>Last Name </th>\
</tr>\n');
// loop through each records in the found set
while (mySet.next())
{
// write out the fields values in a table row
write(' <tr>\
<td>', mySet['Employee Number'], '</td>\
<td>', mySet['First Name'], '</td>\
<td>', mySet['Last Name'], '</td>\
</tr>\n');
}
// create a reference to the URL pointing to the next group of records
var next = mySession.shown_nextGroupURL();
// create a reference to the URL pointing to the previous group of records
var prev = mySession.shown_prevGroupURL();
// start a sub-table to display the next and previous links
write('<tr>\n<td colspan=3>\n<table width="100%">\n<tr>\n');
// is there a previous group of records?
if (prev != '')
{
// write out a link to the previous group of records
write('<td align=left> <a href="', prev, '">«</a> </td>\n');
}
// is there a next group of records?
if (next != '')
{
// write out a link to the next group of records
write('<td align=right> <a href="', next, '">»</a> </td>\n');
}
// close the sub-table
write('</tr>\n</table>\n</td>\n</tr>\n');
// close the main table
write('</table>\n');
}
else
{
// write out the error message returned when the session was executed
write('<font color="#b80021" size="4">', mySession.getResultMessage(), '.');
}
// write out the page footer
footer();
</SERVER>
[Previous Example]