Previous: ZD-Comments| Zot-Dispatch 2.0| Next: Example Forms

Zot-Dispatch: Default Values


There may be times when a value isn't entered by a user, or, because of the browser that is being used, a value isn't returned for an input element. If you are expecting to substitute that missing value into a template, all that you will get is the name of the input element with the pound (#) and dollar ($) signs stripped. This may not be a desirable behavior.

Well thanks to the fact that Zot-Dispatch only substitutes the last value it receives you can set up default values for these input elements. All you need to do is specify them in the form before you specify the input element that the user interacts with.

For our example we will use the following template:

    Did you check the checkbox:  $input-value#
Try submitting the following form without checking the checkbox:
Don't check this box:
You should have seen the following:
   Did you check the checkbox: input-value
Now if you want that space to say "No You Didn't" when nothing is entered, your form should look like:
    <FORM METHOD=POST ACTION="http://www.oac.uci.edu/cgi-bin/zd-2.0.cgi">
    <INPUT TYPE=hidden NAME="input-value" VALUE="No You Didn't">
    <INPUT TYPE=hidden NAME=ZD-Method
        VALUE="ZD-Reflect;;body:Did you check the checkbox: $input-value#">
    Don't check this box: <INPUT TYPE=checkbox SIZE=20 NAME="input-value"
                           VALUE="Yes You Did"><BR>
    <INPUT TYPE=submit VALUE="Submit">
    <INPUT TYPE=reset VALUE="Clear Form">
    <FORM>
Go ahead and try it:
Don't check this box:
This also works great if your default value is the null string. Just remember that the default value must come previous to the input value, or else your default value will always be the one that is substituted.
Previous: ZD-Comments| Zot-Dispatch 2.0| Next: Example Forms
Zot-Dispatch 2.0
Written by Leonard Megliola III (lmegliol@uci.edu)
Last Revised 14 September 1995