Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Client-side Scripting _ How to code an image button to call mail.php on contact form

Posted by: larry78723 Mar 29 2020, 02:28 PM

My contact form starts with:

<form id="form1" method="POST" action="mail.php">

I'd like to replace the last line in my contact from:

<button type="submit" value="Send" style="margin-top:15px; margin-left: 500px; text-align: center;">Send Email</button>

with one that contains

<img src="images/button_send-email.png" alt="Email">

but have no idea what it should look like. I tried <a href "mail.php" <img src="images/button_send-email.png" alt="Email"> > but the button doesn't even show.

Please teach me how this should be done.

Thanks in advance,
Larry

Posted by: Christian J Mar 29 2020, 03:02 PM

QUOTE(larry78723 @ Mar 29 2020, 09:28 PM) *

I'd like to replace the last line in my contact from:

<button type="submit" value="Send" style="margin-top:15px; margin-left: 500px; text-align: center;">Send Email</button>

with one that contains

<img src="images/button_send-email.png" alt="Email">

You might put the IMG element in a BUTTON TYPE=SUBMIT element:

CODE
<button type="submit" name="foo" value="bar"><img src="dog.jpg" width="100" height="50" alt="Send"></button>

(some extra CSS tweaking might be necessary, different browsers often handle form element styling differently).

You can also use TYPE=IMAGE with an INPUT submit button, see https://htmlhelp.com/faq/html/all.html#custom-button

QUOTE
I tried <a href "mail.php" <img src="images/button_send-email.png" alt="Email"> > but the button doesn't even show.

You can't submit forms with HTML links, you need buttons (or, less accessible, the javascript onclick event on any element).

Posted by: larry78723 Mar 29 2020, 05:01 PM

Thanks Christian

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)