Next / Previous / Contents / TCC Help System / NM Tech homepage

12. Image maps

You can use a graphical image instead of a submit button. When a user clicks on that image, the CGI script will be started up and informed of the of the exact pixel coordinates where they clicked. Use a tag with this general form:

<input type="image" name="fieldName" src="imageFile">

where the imageFile is the name of an image file such as a .jpg file.

When the user clicks, your CGI script will be launched. It will receive two name-value pairs identifying the location where the user clicked. The x coordinate will be given as name fieldName.x and the y coordinate as fieldName.y.

For example, suppose you used this tag:

<input type="image" name="dartboard" src="bill.jpg">

Suppose a user clicks on the pixel that is located 319 to the right of the left side, and 114 pixels down from the top edge. Your CGI script would be activated and passed two name-value pairs, dartboard.x with value 319, and dartboard.y with value 114.