Javascript Execution of Rule Sets

Top  Previous  Next

A function is supplied in the common.js Javascript library that is loaded into web forms (note the header line containing fl=common.js).  This function executes a rule set on the server, and the rule set's cgiresponse$ value is returned to Javascript.

 

The syntax of this function is:

 

var txt=runRuleSet("rulefile","ruleset",flds[,args])

 

The rulefile and ruleset arguments are self-explanatory, as they simply become –f and –r arguments to an UnForm job.  The flds argument can be either a URL=encoded string, such as "name=Jim%20Smith", or an JavaScript object containing name:value pairs, in which case the function will URL-encode all the names and values.  The fields defined in this argument are available in the rule set as cgi.name$.  If additional job command line arguments are required, they can be supplied in the optional args string argument.

 

Note if there is data in delimited or INI format available on the server and needed in Javascript, there is a json object that can be used in the rule set to convert such data into JSON format, enabling easier and faster access in the script code.