Drop-down list instead of entry field
Some data is saved in the profile database as a reference number, for instance gender or mail format. It is impossible to ask a subscriber to enter the relevant numerical data on registration. This would not only cause many errors, but will also prompt some people to enter invalid data on purpose. It is much more elegant to offer subscribers a drop-down list for parameter selection. To do this, the tags <select> and <option> are used to define a drop-down list in the HTML form. The following example is suitable for gender selection.
<select name="GENDER" size="1">
<option value="2" selected>no entry</option>
<option value="0">Mr</option>
<option value="1">Mrs</option>
</select>
In the first line, the <select> tag with the name="GENDER" attribute determines that the drop-down list will select the subscriber’s gender. This is a required field since without a gender, OpenEMM cannot process entries correctly.
Please note: The name of the field must be written in upper-case letters.
Fig. 8.20: The registration form from the last example, now with drop-down lists for gender and mail type.
The following lines starting with <option> define the possible selections in the drop-down list. There is one <option> tag per selection. Each <option> tag is attributed a value="" which will be used by OpenEMM to determine which entry to make in the profile database. In our example, we used 0 for male, 1 for female and 2 for no entry.
But what happens if the subscriber does not make a selection? You will define a default entry for this situation. In our example, when evaluating the form the default value will be No entry. This is why the selected attribute is shown against that selection’s <option> tag. This also means that the entry is the default form entry and visible at form call-up.
When defining other selections, for instance the mail format or entries for fields you defined yourself, you must adapt the following data:
• | The field name in the name attribute. |
• | The values (value="") and text for all drop-down list selections (<option> ...</option>). There is no limit to the number of selections you may insert. |