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:

 

{include stdhead_arc.html}

<body>

 

<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]">

 

<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," &gt; ");

                         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()">

                 &nbsp;&nbsp;&nbsp;

                 <input type="button" value="Cancel" onclick="window.close();">

         </td>

 </tr>

</table>

</form>

 

</body>

{include stdfoot_arc.html}

 

<script>

 function submitForm() {

         document.approval.run.value="y";

         document.approval.submit();

 }

</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 opens a new URL, or simply closes the window, using the UnForm browser framework, like these examples:

 

<script>location.href='url-value'</script>

 

<script>top.closeContainer(window);</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.