Re: Image Button
by damian1301 (Curate) on Mar 17, 2001 at 02:09 UTC
|
use CGI 'submit';
print submit(-type=>'image', -src=>"blah.jpg",-name=>'');
:)
Almost a Perl hacker. Dave AKA damian
I encourage you to email me | [reply] [d/l] |
|
|
I tried that and it didn't work. It can't pick up the .pl script.
| [reply] |
|
|
The submit function sends the form to the current script by default.
If you want to send it to a different script (as it seems you do), add an action
tag:
print submit(-type=>'image',-src=>"blah.jpg",-name=>'',-action=>'yours
+cript.pl');
buckaduck | [reply] [d/l] |
Re: Image Button
by Masem (Monsignor) on Mar 17, 2001 at 02:19 UTC
|
If you use a type="image", it acts like an image map for CGI. Thus, you should be able to do:
<FORM METHOD="POST" ACTION="./yourscript.pl">
<INPUT TYPE="IMAGE" NAME="submit1" SRC="image1.gif">
<INPUT TYPE="IMAGE" NAME="submit2" SRC="image2.gif">
</FORM>
Then CGI.pm should have values for "submit1.x" and "submit1.y" if the first one is pressed, and similar for the second. So you can check for defined() values to determine which was pressed.
The only problem with image submits like this is that you cannot have an image reset button without resorting to JavaScript.
Dr. Michael K. Neylon - mneylon-pm@masemware.com
||
"You've left the lens cap of your mind on again, Pinky" - The Brain
| [reply] [d/l] |
|
|
I tried this but i get an error reading the image.
| [reply] |
Re: Image Button
by dfog (Scribe) on Mar 17, 2001 at 01:54 UTC
|
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 | [reply] [d/l] |
|
|
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
| [reply] |
|
|
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
| [reply] [d/l] |
|
|
|
|
Re: Image Button
by elusion (Curate) on Mar 17, 2001 at 02:22 UTC
|
I think you can do this is done pretty easily with javascript. Try this:
<a href='javascript:document.--insert form name--.submit()'>
<img src='button.jpg'>
</a>
- p u n k k i d
"Reality is merely an illusion,
albeit a very persistent one."
-Albert Einstein | [reply] [d/l] |