Choosing Fruits JavaScript Style

by

William Overington

Here is a fun survey to choose which three fruits from ten listed fruits you prefer and email your choices. The purpose of this page is to demonstrate using JavaScript to check the data supplied on a form before emailing it. Here the JavaScript software checks the form to ensure that 3 and no more than 3 fruits have been chosen. The types of fruits included in the survey were chosen so as to suit the clip art available! A particular fruit is chosen by clicking the mouse in the checkbox that is to the left of the name of the fruit. Clicking in a box that is already checked will uncheck it. Please try to submit your choices with only 2 boxes checked and then try with 4 or more boxes checked. When you have 3 boxes checked your response is accepted and an attempt to email your choices to the survey will be made. You are welcome to cancel the email being sent if you wish. However, if you would like to let it be sent, it is pleasant to receive emails from the email points in our family webspace that show that the pages are being helpful and enjoyed.

You might like to make a copy of the file for use locally offline on your own system and alter the source code to have your email address in the ACTION= section of the FORM statement of the code. You can then receive the email yourself so that you can observe the manner in which your system receives such a survey form.

Responses from a form such as this arrive here as email with an attachment file. The user responses are in the attachment file. I save the attachment file with a filename that has .htm as the extension and then read the file with Internet Explorer. The information sent by the user is then clearly displayed.

Cherry

Banana

Grapefruit

Grape

Pineapple

Strawberry

Kiwi Fruit

Blueberry

Plum

Pear

Initial version 10 October 1998
Copyright 1998 William Overington