HTML Form Structure |
Top Previous Next |
The HTML form may have any valid HTML structure for a form, but must contain a few mandatory elements. The form_sample.html file found in web/en-us provides this example form code:
<!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="[SCRIPT_NAME]?fl=default.css" /> <link rel="stylesheet" type="text/css" href="[SCRIPT_NAME]?fl=custom.css" /> <script src="[SCRIPT_NAME]?fl=common.js"></script> <title> Document Approval </title> </head> <body onunload="saveWindowInfo()">
<h2>Approve or Deny Action on this document</h2>
<form name="approval" action="[SCRIPT_NAME]" method="post"> <input type="hidden" name="a" value="uf"> <input type="hidden" name="args" value="-f cgiforms.rul -r approval -p pdf"> <input type="hidden" name="run" value=""> <input type="hidden" name="async" value="0"> <input type="hidden" name="lb" value="[lb]"> <input type="hidden" name="doctype" value="[doctype]"> <input type="hidden" name="docid" value="[docid]"> <input type="hidden" name="option" value="[option]">
<table class="form"> <tr> <th>Library</th> <td>[lb]</td> </tr> <tr> <th>Doc Type</th> <td>[doctype]</td> </tr> <tr> <th>Doc ID</th> <td>[docid]</td> </tr> <tr> <th>Categories</th> <td> <script> // present categories in lines var cat='[categories]'; cat=cat.replace(/;/g,"<br>"); cat=cat.replace(/\|/g," > "); document.write(cat);
</script> </td> </tr> <tr> <th>Approval</th> <td> <input type="radio" name="approval" value="0" checked>Denied<br> <input type="radio" name="approval" value="1">Approved<br> </td> </tr> <tr> <td colspan="2" style="text-align:center;"> <input type="button" value="Submit" onclick="submitForm()"> <input type="button" value="Cancel" onclick="window.close();"> </td> </tr> </table> </form>
</body> </html> <script> function submitForm() { document.approval.run.value="y"; document.approval.submit(); } //obtain query string values var library=queryValue("lb"); var option=queryValue("option"); </script>
This example shows a form related to particular document, identified by the CGI fields lb, doctype, and docid. Document field values are represented by tags [fieldname], where the field name can be any of lb, doctype, docid, date, time, title, entityid, notes, keywords, categories, links, dateupdated, and timeupdated. Date fields are provided in YYYYMMDD format, time fields in HH:MM:SS format, keywords and links in semicolon-delimited format, categories in semicolon (category), vertical bar (segment) delimited format, and notes with hard line breaks represented as "\n" literal sequences.
In the form above, notice how javascript code is used to display categories with different line and segment delimiters.
Several fields must submitted with the form in addition to lb, doctype, and docid. These include a (set to "uf"), args (set to a string of command line arguments), and run (set to a non-null value when the form is submitted (see the submitForm() function at the bottom of the document). Optionally, the async field can be set to 1 to run the UnForm job asynchronously. When this happens, the browser response is based on the form_async.html document found in web/en-us (or web/language if configured). Otherwise, the browser response is either the UnForm job output (typically a PDF file) or a text response set into the cgiresponse$ variable in one of the job's code blocks.
It is possible to have the text response contain script code that simply closes the window:
<script>window.close();</script>
The variable args is especially important, as it specifies, at a minimum, the rule file and rule set to execute when the form is submitted. It may also supply other options, such as -prm parameters, or a -p pdf if the job's output will be the response to the browser.
|