in reply to Image Button

Just because I have been too lazy to learn the uses of CGI.pm for my multitude of html chores, i use the straight html. In HTML, the syntax is :
<input type="IMG" name="SubmitImage" src="button.jpg" border="0">

Dave

Replies are listed 'Best First'.
Re: Re: Image Button
by jeffpflueger (Beadle) on Mar 17, 2001 at 02:02 UTC
    The thing is, submit allows a name/value, so you don't need the hidden field, but as far as I have found, input type=img src doesn't support a name/value so you need a hidden if you want to use it as the equivalent as a submit button...

    but then the problem is how to use multiple type=img src buttons in the same form to submit different values like you can with submit buttons.

    I've been stuck on that one too, and haven't quite figured it out.

    "No matter where you go, there you are." Jeff Pflueger - Struggling Perl knowledge sponge

      I'm not sure they actually pass a value, as in value="$value", but they do pass the x and y coordinates of where the user clicked. Lets say you put two images in the same form named ImageSubmit1 and ImageSubmit2, you could check which one they clicked by using
      if (defined($cgi->param('ImageSubmit1.x')) { #Do some code associated with ImageSubmit1 } elsif (defined($cgi->param('ImageSubmit2.x')) { #Do some code associated with ImageSubmit2 }
      This way you can figure out what image the user clicked on.

      Dave
        Maybe, but I think that it is x and y for each individual image. So unless one made sneaky buttons that had different areas people would want to click on, this wouldn't quite work, and definately wouldn't work if the images didn't show up at all, and just the ALT text (for a blind user, someone with images off, etc) "No matter where you go, there you are." Jeff Pflueger - Struggling Perl knowledge sponge