Most form elements follow a pattern where the name translates exactly to a hash table hierarchy of keys, with the element value at the bottom. Form elements that follow this pattern are TEXT, TEXTAREA, HIDDEN, and FILE. Form elements that do not follow this pattern are RADIO buttons, SELECT lists, and CHECKBOXes, due to the way they are named and the way the values are represented.
RADIO buttons:
To form a radio button group, HTML requires that all radio buttons in the group have the same name. For example, suppose you defined the following button group in HTML named biodata_age:
<INPUT type="radio" name="biodata_age"
value="junior"></INPUT> <
30
<INPUT type="radio" name="biodata_age" value="middle"
checked="checked"></INPUT>30 to 64
<INPUT type="radio" name="biodata_age"
value="senior"></INPUT> >
65
This creates the following hash table structure:
Key | Value | Value Type |
---|---|---|
biodata |
(sub-hashtable) | Hashtable |
age |
“middle” | string |
The actual values in the Value column of the table depend on which button the user checked when the form was used or what the form defaults are.
SELECT lists:
SELECT lists have a single name, but multiple OPTIONs. Depending on how the SELECT list is defined, a user may select only one option or several options. For example, suppose you defined the following SELECT list in HTML named biodata_status:
<select name="biodata_status">
<option value="employed"
selected="selected">Employed</option>
<option value="unemployed">Unemployed</option>
<option value="retired">Retired</option>
</select>
This creates the following hash table structure:
Key | Value | Value Type |
---|---|---|
biodata |
(sub-hashtable) | Hashtable |
status |
“employed” | string |
The value shown in the hash table is what would result from the defaults given in the HTML sample. If you specify MULTIPLE in the SELECT tag, then the value will contain a comma- delimited list of values. For example, suppose you defined the following SELECT list in HTML named biodata_status:
<select multiple="multiple" name="biodata_status">
<option value="employed" selected="selected">Employed</option>
<option value="unemployed">Unemployed</option>
<option value="retired">Retired</option>
<option value="other" selected="selected">Other</option>
</select>
This creates the following hash table structure:
Key | Value | Value Type |
---|---|---|
biodata |
(sub-hashtable) | Hashtable |
status |
“employed”, “other” | string |
The value shown in the hash table is what would result from the user selecting both employed and other in the multiple select list.
CHECKBOX fields
Check boxes take the value assigned to the value field if selected. For example, suppose you defined the following CHECKBOX field:
<INPUT type="checkbox" name=
"biodata_other" value=
"glasses">Do you wear glasses?</INPUT>
This creates the following hash table structure:
Key | Value | Value Type |
---|---|---|
biodata |
(sub-hashtable) | Hashtable |
other |
“glasses” | string |
Again, values in this table reflect the result of the user selecting the check box. If the user does not check the box, the value will equal unselected.