HTML Forms - Sending Data with a Form
(Page 5 of 6 )
We mentioned the Submit button above. In this section we are going to use it, along with the action attribute to send data to a web page that would usually have some code to do something with the information we collect. For more on how to work with information from HTML forms, you can read my series on ASP or PHP (shameless self plug).
For now, here is how you create the form:
<html>
<body>
<form name="wookie" action="sample.asp" method="get">
Please Enter Your Name:
<input type="text" name="name" value="Bruce Digelow" size="25">
<br>Please Enter Your Occupation:
<input type="text" name="occupation" value="Male Jiggler" size="25">
<br>
<input type="submit" value="Submit">
</form>
<p>
When you click the Submit button, it sends the data to a page called, "sample.asp". At least, it would if you had such a page on your server.
</p>
</body>
</html>
This results in the following:
When you click the Submit button, it sends the data to a page called "sample.asp." Well, it would if you had such a page on your server.
When the user clicks the Submit button, it sends the information to the file listed in the action attribute (in this case sample.asp).
Sending Data from Checkboxes
You can of course also send the results of checkboxes to a page. Here is how:
<html>
<body>
<p>Things that describe me:
<form name="input" action="sample.asp" method="get">
I am fat:
<input type="checkbox" name="descrip" value="fat" checked="checked" />
<br />
I wear glasses:
<input type="checkbox" name="descrip" value="fat" />
<br />
I have a sloppy haircut:
<input type="checkbox" name="descrip" value="fat" />
<br /><br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
The result:
Things that describe me:
And of course this works with the other input types as well, such as the radio button:
<html>
<body>
<form name="input" action="sample.asp" method="get">
Yes:
<input type="radio" name="maybe" value="Yes" checked="checked">
<br>
No:
<input type="radio" name="maybe" value="No">
<br><br>
<input type ="submit" value ="Submit">
</form>
</body>
</html>
Next: Sending E-Mail Via Forms >>
More HTML Articles
More By James Payne