utfrmgen.wbb - Generate Form Input Tags from a Template and an Optional List of Fields and Parameters
Syntax
CALL "utfrmgen.wbb",tpl$,flds$,captions$,flags$,captags$,work$
Description
This high-level program generates the input tags for an HTML form (or part of a form), based on a template and other information. It is also capable of creating the form as loose text, preformatted and aligned text, or as a bordered or borderless table.
Parameter |
Description |
---|---|
tpl$ |
Data template that contains both the fields and data to generate the form input fields. A variety of user-attributes can be defined in the template to control how field data is handled. See Data Templates for an explanation of these attributes. |
flds$ |
Text string that contains a comma-delimited list of field names and optional format options. If flds$ is null, then a default list is generated from all the fields in tpl$. flds$ can refer to individual array elements (name-n) or to all array elements (name-*), in which case the form is generated with all defined array elements separated by a <BR> tag within the column. If flds$ begins with "*,", it is assumed to contain a list of exceptions, so that all the fields in the template tpl$ are used to generate the HTML output. Those found in flds$ are referenced with the formatting tags included in flds$ (for example, if flds$ contained the data "*,type checkbox keys="1;2" vals="Type 1;Type 2"", then all fields in the template would be generated, and the field "type" would be treated as a checkbox input.) See the utfrmout.wbb program documentation for information about formatting options. |
captions$ |
String template that contains captions for any field to be included in the form (any in flds$, or if flds$ is null, then any field in tpl$.) The data for any field found in captions$ is used as the caption for the field. If a field to be used on the form is not present in captions$, and the user attribute "caption" is not present in the template, a default caption is generated from the field name by converting underscores to spaces and formatting the name with proper case. A null field in captions$ results in no caption for that field. |
flags$ |
Text string containing formatting controls, each separated by at least one space, in any order. The supported flags are listed in the table below. |
captags$ |
Text string that contains any tag used to format the captions before being placing in HTML form. This string is used in a CALL to uttags.wbb. Refer to that program page for additional information. |
work$ |
Text string that returns the HTML version of the form. This form is incomplete as returned and needs a submit button and the <form> </form> HTML tags. It may be necessary to use this feature to build a form from several data templates. |
Flag |
Description |
---|---|
table |
Formats the captions and input fields in table columns, one row per field. |
pre |
Use pre-format tags to format the form, allowing perfect column alignment without relying on table structures but using fixed pitch fonts. |
<p> |
Indicates there should be extra space between each row. |
align=left, center, right |
Sets horizontal alignment for table captions. |
cellalign=left, center, right |
Sets the horizontal alignment for table data cells. |
valign=top, bottom |
Sets vertical alignment to "top" or "bottom" for tables. |
borderborder=n |
For table forms, there should be a border around each cell. |
hdropt=options cellopt=options |
Adds options to the <th> and <td> tags, respectively. No spaces are allowed, but underscores can be used for multiple options. "hdropt=bgcolor=red_align=right", for example, generates <th bgcolor=red align=right>. |
font=fontopts hdrfont=fontopts |
Adds a <font fontopts> tag to each data cell and caption cell, respectively. Use underscores for spaces. For Example, "size=4_color=black" adds <font size=4 color=black> and </font> tags to the data. |
right |
Captions are placed to the right of the input fields. |
top |
Captions are placed above the input fields. In addition, if "pre" or "table" is specified, the data is arranged in columns, and array values in the template are scrolled within the column. |
The following code creates a simple form:
CALL "utcgi.wbb",env$,cgi$,errmsg$
rem - generate heading
CALL "uttags.wbb","h1","Customer Update Form",html$
rem - create template for new customer
dim rec$:"id:c(5), name:c(40), street:c(40), city:c(30), state:c(2):case=upper:, zip:c(9):mask=00000-0000:"
rem - if existing customer, the rec$ template could be filled here
rem - create form fields in table format - note ID is a hidden field and can't be changed
CALL "utfrmgen.wbb",rec$,"id hidden,name,street,city,state,zip","","table border","",formhtml$
rem - add submit button
CALL "uttags.wbb","submit","",formhtml$
rem - add form tags to form, append to html$; script to perform update is "/cgi-bin/custupdt"
CALL "uttags.wbb","form /cgi-bin/custupdt",formhtml$,html$
rem - send out form in html$ to browser
CALL "utsend.wbb",html$
CALL "utexit.wbb",cgi$