Developer’s Guide

Table Of Contents
10-16 Developer’s Guide
JavaScript scripting language example
Using HTML and a scripting language with your XML document
can allow your web users to interact with the database after it has
been downloaded. For example, a simple onClick scripting event
handler can allow web users to click a button and see different
records in the database.
This example demonstrates the use of the JavaScript scripting
language with an XML document to publish the People.fp5 database
on a web page. It starts with an HTML file, named People_form.htm,
that 1) references the JavaScript library, FMP.js, 2) contains a simple
HTML form with a table for the field and picture rows, and 3) builds
and executes a CGI command to FileMaker Pro to find and
download all the records in the People.fp5 database.
With JavaScript, you can manipulate the data
in the XML document to display different
records in the database—after the data has
been downloaded
Note The FMP.js JavaScript library was created for the XML
Inventory example, described next, which is a more complex and
sophisticated example of the use of JavaScript and the W3C
Document Object Model with your XML documents.
Once the people_form.htm page is loaded in the browser, the onLoad
event handler performs the “initialize” function, creating an
ActiveXObject and building the FMPFindRequest:
function initialize ( )
{
var xmlDocument = new ActiveXObject (“Microsoft.XMLDOM”);
xmlDocument.async = false;
var ndRequest = new FMPFindRequest (“people.fp5”, null, AND,
false);
if (xmlDocument.load(ndRequest.getRelativeURL( ) ) )
{
foundSet = new FMPFoundSet (xmlDocument);
populateFields( );
}
else
alert (“Error retrieving records.”);
}
The xmlDocument and findRequest variables are referenced from
the FMP.js JavaScript library. The values in the new
FMPFindRequest are people for the name of the database, null for no
layout, AND for the find criteria’s logical operator, and false for no
XML DTD to be generated as a result of the request.
In the People_form.htm page, the nextRecord and previousRecord
functions are assigned to the onClick event handler of the Next and
Previous buttons respectively, so that when web users click the
buttons, the function is performed and the fields are re-populated
with new data.