html forms tutorialIn this easy html forms tutorial you will discover how to build a form step by step with an example for each form tag and learn how to use mailto or cgi to send the formIn simple lessons this page will describe all aspects of the html form including, text, radio buttons, check boxes, textarea, the drop down menu, password, hidden input and using an image as a submit button The form tagstart with the form tag, an example of how to use the the mailto tag in a html formwhen the user clicks the submit button the user's browser will send the information to someone@$nailmail.com in this case <FORM METHOD=POST ACTION="mailto:someone@$nailmail.com" ENCTYPE="text/plain"> </FORM> data can be sent to multiple email address's, simply seperate the address's with commas someone@$nailmail.com, someoneelse@$nailmail.com, noone@$nailmail.com Add a text input<INPUT NAME="PASS" TYPE="password" SIZE=12>an example of radio buttons<INPUT TYPE="radio" NAME="NEWSLETTER" VALUE="SUBCRIBE" CHECKED> Subscribe<INPUT TYPE="radio" NAME="NEWSLETTER" VALUE="UNSUBSCRIBE"> Unsubscribe radio buttons must have a 'value', radio inputs should have the same 'name' because they only give the user one possible option It is possible to offer the user more options with radio inputs by giving them a different 'name' <INPUT TYPE="radio" NAME="NEWSLETTER" VALUE="SUBCRIBE" CHECKED> Subscribe <INPUT TYPE="radio" NAME="NEWSLETTER" VALUE="UNSUBSCRIBE"> Unsubscribe <BR> <INPUT TYPE="radio" NAME="ATTACHMENT" VALUE="INCLUDE" CHECKED> Include attachment <INPUT TYPE="radio" NAME="ATTACHMENT" VALUE="NOT-INCLUDE"> Don't include attachment The checkboxIt may help to think of the checkbox as the opposite of a radio input because the 'name' changes and the 'value' stays the same<INPUT TYPE="checkbox" VALUE="YES" NAME="OPTION1" CHECKED> option 1 <INPUT TYPE="checkbox" VALUE="YES" NAME="OPTION2"> option 2 <INPUT TYPE="checkbox" VALUE="YES" NAME="OPTION3" CHECKED> option 3 <INPUT TYPE="checkbox" VALUE="YES" NAME="OPTION4"> option 4 just as it is possible to create more than one 'set' of radio buttons by changing the 'name' additional checkbox catagories or options can be included by changing the 'value' The textareaNote that 'textarea' has a closing tag, <TEXTAREA NAME="COMMENTS" ROWS=10 COLS=20> </TEXTAREA> note also that anything typed between the textarea opening and closing tags will be formated exactly as it was typed by most browsers <TEXTAREA NAME="COMMENTS" ROWS=10 COLS=20 READONLY> this textarea is 40 'cols' wide and 10 'rows' in height </TEXTAREA> This textareas is READONLY in Internet Explorer the drop down menusometimes known as a pull down menu uses <SELECT> and <OPTION> tags a 'name' is given to the <SELECT> tag and a value is applied to each <OPTION> tag<SELECT NAME="INGREDIENTS"> <OPTION VALUE="EGGS">Eggs <OPTION VALUE="PASTA">Pasta <OPTION VALUE="SUGAR">Sugar <OPTION VALUE="CHEESE" SELECTED>Cheese <OPTION VALUE="BREAD">Bread <OPTION VALUE="MILK">Milk </SELECT> Note that one of the items on the list is 'SELECTED' otherwise the default selected option would be the top one (Eggs) It's simple to transform the drop menu into a scrolling menu by adding a size to the <SELECT> tag
input type hiddenanother very useful tag is the<INPUT NAME="SECRET" TYPE="hidden" VALUE="non-displayed-data"> about next_url a very special hidden input type uses <INPUT NAME="next_url" TYPE="hidden" VALUE="http://www.abc.com/index.html"> when using submit and resetone of the most simple form tags of all, this basic format displays<INPUT TYPE="submit"> <INPUT TYPE="reset"> In this next example 'submit' and 'reset' are given a 'value'
the image submit button it's easy to substitute an image for the submit button, input type="submit" and input type="image" are interpreted by the browser as one and the same
<INPUT TYPE="image" SRC="search.gif" WIDTH="55" HEIGHT="18" BORDER=0 ALT="Send"> input file typewhen usingwhenever this input is used, <FORM METHOD=POST ACTION="mailto:someone@$nailmail.com" ENCTYPE="multipart/form-data"> <INPUT TYPE="file" NAME="upload"> </FORM> It should be noted that older browser tend not to support this type of input and when this input is used in a mailto form, the results can sometimes be unpredictable. the problem with mailtounfortunatly mailto will not work for a small number of user'sThe reliable alternative to mailto is to use a cgi script and many servers give their user's free access, if so the instructions for setting up and using the When using a cgi form the action will be set to something like this... ACTION="/cgi-bin/mail.pl" there may also be one or two extra <INPUT TYPE=hidden NAME="recipient" VALUE="someone@$nailmail.com"> <INPUT TYPE=hidden NAME="redirect" value="http://www.server.com/formsent.html"> If your server has a cgi bin you may even be able to run your own cgi script, there are many scripts of this kind freely available on the web and if there is no cgi access avilable on your server whatsoever then there are free remotely hosted cgi form handling scripts available for use by anyone build this formThe complete html code for this mailto form isAlso available is a source code for a home html tutorial css tutorial javascript webmaster articles link exchange |
html tutorial make money from your website |