Re: Re: calling javascript function from a form image
| From: | Neil Freeman | Date: | Mon, 24 Sep 2001 08:07:10 +0000 |
| Subject: | Re: Re: calling javascript function from a form image | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-68489@lists.php.net to get a copy of this message | ||
Yeah thanks, I've done something along the lines of what you've provided and
it works great. Thanks for your help.
Chris Lee wrote:
> this isnt reallt a php question but I'll answer it anyhow because Ive been
> stuck with netscapes incompatabilities before. do this.
>
> <input type=image border="0" name="sub" src="genre.png"
> onsubmit="set_category()">
>
> if that doesnt work you'll have todo this.
>
> <script>
> function set_category()
> {
> alert("category set");
> document.formMoviesSearch.submit();
> }
> </script>
> ...
> <input type='hidden' name='sub' value=''>
> <img src="genre.png" onclick="set_category()">
>
> or if you want the hand to show up over the image. change the <img> tag to
>
> <a href='javascript: set_category()'><img
> src="genre.png"></a>
>
> --
>
> Chris Lee
> lee@mediawaveonline.com
>
> "Neil Freeman" <neil.freeman@asa.co.uk> wrote in message
> news:3BAB51B3.65C8CDBD@asa.co.uk...
> > Hi,
> >
> > I have a form which contains an:
> > <input type=image
> >
> > When the user clicks this image I want a javascript function to be
> > called. I have added an onclick event to this input line (see code
> > below) which works great in IE and all is well. Netscape doesn't
> > recognise this onclick event though for the image so how do you call a
> > javascript function here? Normally I'd wrap an <img with <a></a> tags
> > but I don't think a form will like this.
> >
> > Has anyone a solution?
> >
> > Here is my code
> >
> > #############################
> > <head>
> > <title>imagesubmit.htm</title>
> >
> > <script>
> > function set_category() {
> > alert("category set");
> > }
> > </script>
> > </head>
> >
> > <body bgcolor="#FFFFFF" text="#000000">
> >
> > <?php
> >
> > if ($submit_form) //if this equals true then the form has been
> > submitted
> > {
> > echo "<script>alert(\"form submitted\");</script>";
> > }
> > else
> > {
> > echo "<script>alert(\"not submitted\");</script>";
> > }
> >
> > ?>
> >
> > <form name="formMoviesSearch" method="post"
> > action="imagesubmit.htm">
> >
> > <input type=image border="0" name="sub" src="genre.png"
> > onclick="set_category()">
> > <input type="hidden" name="submit_form" value="true">
> >
> > </form>
> >
> > </body>
> > </html>
> > #############################
> >
> > Neil
> >
> > --------------------------------
> > Email: neil.freeman@asa.co.uk
> > neil_freeman@yahoo.com
> > --------------------------------
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
> ***************************************************************
> This message was virus checked with: SAVI 3.49
> last updated 19th September 2001
> ***************************************************************
--
--------------------------------
Email: neil.freeman@asa.co.uk
neil_freeman@yahoo.com
--------------------------------