Forms

8TML > Reference

A form is an extension block of type form:

:::form post guestbook.php
## Sign the guestbook
? text     name   max=20            Your name
? password pw     max=16            Password
? area     msg    rows=3 max=200    Message
? radio    mach   value=c64 checked Visiting with a C64
? radio    mach   value=zx          ... a ZX Spectrum
? select   from                     Found me via
+ town   T8wn
- plot   A friend's plot
- other  Somewhere else
? check    notify value=yes         Tell me about new diary pages
? hidden   token  value=a81f
? submit   send   value=ok          Sign it
:::

Preview: Commodore 64, 40 columns

                                            
Sign the guestbook
Your name [____________________]
Password [________________]
Message
[______________________________________]
[______________________________________]
[______________________________________]
(*) Visiting with a C64
( ) ... a ZX Spectrum
Found me via [T8wn v]
[ ] Tell me about new diary pages
< Sign it >

The form block

  • :::form METHOD URL opens a form. METHOD is get or post; URL is where the form is sent, relative to the page.
  • A missing or unknown METHOD means get. A form without a URL is sent to the page’s own address.
  • A line that is exactly ::: closes it. A form that is never closed ends at the end of the file and still works.
  • Inside, lines starting with ? are fields, and option lines follow a select. Every other line is normal 8TML: paragraphs, headings, lists and so on.
  • A page can have several forms. Forms don’t nest: a :::form line inside a form is ignored.
  • Outside a form, ? lines are ordinary text.

Field lines

? TYPE NAME OPTIONS LABEL
  • TYPE is one of the field types below.
  • NAME is the name sent to the server: ASCII letters, digits, - and ..
  • OPTIONS are key=value words from this list: max, rows, value, and checked (without a value). A value with spaces is written in double quotes: value="hello world".
  • LABEL is the rest of the line, and may contain inline markup.

After the name, the line is read word by word: checked and key=value words with a known key are options, and the first other word starts the label. So a label can’t start with an option word such as max=3. A max or rows value that isn’t a positive number is ignored.

A field line with an unknown type or without a name is ignored.

Type Field
text, password one line of text; password input is masked
area several lines of text
check a checkbox
radio one of a group
select a listbox with option lines
hidden a value the reader doesn’t see
submit, reset buttons

On the screen

  • The client lays out each field with its label: on one line if it fits, otherwise the label above the field.
  • Typical looks: [________] for text, [****____] for passwords, [x] for checkboxes, (*) for radio buttons, [T8wn v] for a listbox, < Sign it > for a button.
  • Fields are styled by the stylesheet keys field and, while selected, field-sel.
  • Fields and links share one focus order, in page order. Activating a field edits it in place (scrolling sideways when the value is longer than the box), toggles it, opens the listbox or presses the button.

Minimums

Every client supports at least 16 fields per form, 80 characters per text or password field and 255 per area. Clients may allow more.

How the data travels to the server is described under Sending.