Forms: submit - A Smarter Way To Learn HTML & CSS (2015)

A Smarter Way To Learn HTML & CSS(2015)

52
Forms: submit

Let’s add a submit button to the form. When the user clicks it, the form is submitted. That is, all the data is sent to the program (PHP or another language) that processes it.

This is the code.

<form action="send-email.php" method="post">
Last name:
<br>
<input type="text" name="surname" size="25"maxlength="40">
<br><br>
Message:
<br>
<textarea name="message" rows="4" cols="30"></textarea>
<br><br>
<input type="submit" value="Send email message">
</form>

This is a simple input tag, with only two parts. The first part creates the button that, when clicked, submits the form:

input type="submit"

The second part specifies the button text. Instead of “Send email message,” it could be “Submit,” “Send,” “Subscribe,” “Purchase,” or any other text you want…

value="Send email message"

The submit tag creates a standard button. If you want a custom button, create your own button image and write a tag like this.

<input type="image" src="images/subscribe-button.png" alt="Sign up" width="72" height="18">

The browser knows this is a Submit button even though you say the input type is "image". Everything you write after <input type="image" is exactly the same as the img tag you learned to write in Chapter 24.

In your HTML file add a Submit button to the form you’ve already created. Save the file. Display the page. Sample HTML code is at:
http://asmarterwaytolearn.com/htmlcss/practice-52-1.html.

Find the interactive coding exercises for this chapter at:
http://www.ASmarterWayToLearn.com/htmlcss/52.html