An image field is a graphical replacement for a standard HTML submit button. The image field is clickable, and it works exactly like a submit button in that clicking it sends the form data to the Web server. The advantage to replacing a submit button with an image field is that you get to use whatever image file you like to submit the form, as in Figure 68.5. You don't have to accept the standard and generally ugly button widget that comes with your browser. Listing 68.5. View Source for Figure 68.5.<form> <input type="image" name="goButton" src="/books/2/30/1/html/2/images/go.gif" width="20" height="20"> </form> Figure 68.5. Use an image field in place of a standard submit button.The src attribute contains the path to the image field's graphic file, and the width and height attributes supply the width and height of the image, just as in the img tag. Replacing a Reset ButtonImage fields always submit form data. There's no way to change an image field so that it functions as a reset button, for example. But don't let that stop you. Just use a regular image tag. Drop anchor tags around the image to make it clickable, and then add a simple JavaScript function to duplicate the reset behavior. Here's the complete script, plus a sample link:
Replacing a Generic ButtonAlong the same lines, you can use an image to launch a JavaScript function and replace the generic button widget. Try something like this:
|