Developer’s Guide

Table Of Contents
7-16 Developer’s Guide
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 findRequest = new FMPFindRequest (“people.fp5”, null, AND,
false);
if (xmlDocument.load(findRequest.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.
function nextRecord( )
{
if (foundSet.nextRecord( ))
populateFields( );
}
function previousRecord( )
{
if (foundSet.previousRecord( ))
populateFields( );
}
function populateFields( )
{
document.getElementsByName(“Name”) . item(0) . value =
foundSet.getFieldByName (“Name”);
document.getElementsByName(“Title”) . item(0) . value =
foundSet.getFieldByName (“Title”);
document.getElementsByName(“Phone”) . item(0) . value =
foundSet.getFieldByName (“Phone”);
document.getElementsByName(“Picture”) . item(0) . src =
foundSet.getFieldByName (“Picture”);
}
Looking at the XML Inventory example
The XML Inventory example is a demonstration of a web-published
database that uses the FMPXMLRESULT and FMPXMLLAYOUT
grammars and Dynamic HTML (including JavaScript and the W3C
Document Object Model) to display the XML data on the Web.