Form Creation

import com.screenscraper.util.form.*;

// The form text being built should include the form open and close tag.
// Any inputs are used, not just what is inside the form tags, so
// limit the input text to the form area.  If there is only one
// form on the page you can use scrapeableFile.getContentBodyOnly()
// as this doesn't care what additional text is included.
Form form = scrapeableFile.buildForm(dataRecord.get("TEXT"));

// Be sure to save the form in a session variable so it can be used
// by the scrapeable file which will use the form data
session.setVariable("_FORM", form);

// The form object is now ready to be used to submit what is currently
// on the page, or can be manipulated with input values being set

// Set a value on the form.  If the form didn't contain that input key,
// one will be added for it
form.setValue("zip", "12345");

// Set a value on the form, but validate it can be set to that.  This isn't
// fool proof, but does some checking.  For instance, if the input was
// a select type, it will throw an exception if there wasn't an option
// with the given value.  It also handles some other error checking based
// on the input type, but any Javascript checks won't be checked
form.setValueChecked("selector", "op1");

// Remove the specified input from the form.  This is useful if there are
// multiple submit buttons, for instance.  In that case the one that
// is clicked on is the value sent to the server..
form.removeInput("Update");