The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> How to code an image button to call mail.php on contact form
larry78723
post Mar 29 2020, 02:28 PM
Post #1


Member
***

Group: Members
Posts: 39
Joined: 5-March 20
Member No.: 27,220



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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 29 2020, 03:02 PM
Post #2


.
********

Group: WDG Moderators
Posts: 9,628
Joined: 10-August 06
Member No.: 7



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).
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
larry78723
post Mar 29 2020, 05:01 PM
Post #3


Member
***

Group: Members
Posts: 39
Joined: 5-March 20
Member No.: 27,220



Thanks Christian
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 18th March 2024 - 10:39 PM