WebDevelopersNotes logo

home-icon Home / HTML / HTML form – forms in HTML part 2

HTML form – forms in HTML part 2

HTML form - forms in HTML part 2

HTML form <INPUT TYPE=”BUTTON”>

This creates a button which is quite useful for triggering JavaScript events.

  • NAME: Specifies a name for the button.
  • VALUE: Determines what is written on the button.
<INPUT TYPE="BUTTON" NAME="pbut" VALUE="Push Me">

The button above does nothing when clicked. However, you can attach JavaScript event handlers to this button to set up some kind of action.

<INPUT TYPE="BUTTON" VALUE="Push me to get a greeting" 
NAME="mybut" onclick="return disp();">

The HTML form RESET button

Creates a reset button, which when clicked, clears all form elements and sets then to their default values. It has only one attribute VALUE, that specifies the text written on the button.

<INPUT TYPE="RESET" VALUE="Clear the form">

The HTML form SUBMIT button

Makes a button, which when clicked, submits the form. It has two attributes

  • VALUE: Puts text on the button.
  • NAME: Names the submit button. Its value is generally used by server side scripts to determine if the form has been submitted.
<INPUT TYPE="SUBMIT" VALUE="Send Email" NAME="semail">

Clicking on a submit button sends the name-value pairs of all form elements to the server. (Note: This submit button does not work. However, you can test one on the right to join my mailing list!)

<INPUT TYPE=”FILE”>

Allows your users to send files to your server. It is accompanied with a Browse button that helps the user locate the file on his computer.

Attributes taken are:

  • ACCEPT: Its value is a MIME type/s that your server program is ready to accept. A comma-separated list of mime types can be supplied.
  • NAME: Specifies a name for the element.
  • VALUE: Specifies the default text inside the text field.
<INPUT TYPE="FILE" NAME="uploadfile" VALUE="">

<INPUT TYPE=”IMAGE”>

This is a great tag allowing designers to make their own buttons. With its use you can replace the dull default button with a colorful image.

There are four attributes associated with this tag

  • SRC: a required attribute that points to the URL of the image file.
  • NAME: Gives a name to the element.
  • ALIGN: aligns the surrounding text with respect to the image.
  • BORDER: sets the border around the image. If zero is assigned as its value, no border is displayed.
<INPUT TYPE="IMAGE" SRC="but.gif" NAME="sub_but" BORDER="0">

<INPUT TYPE=”HIDDEN”>

This creates a form input field which is not displayed in the browser. It is ideal for passing values set by the programmer or by certain actions of the user.

It has only two attributes.

  • NAME: Defines a name for the element.
  • VALUE: Sets a value for the element.
<INPUT TYPE="HIDDEN" NAME="birthday" VALUE="16-03-72">

Sponsored Links

Your comments
Star icon IMPORTANT Have a question / problem? Click here to ask an expert.

Sponsored Links

Tips

How do I view a deleted web page?
Is there a way to view a deleted web page - one that is no longer available? Yes there is and the solution is quite simple. [more...]

Fact

Brewster Kahle created the Internet Archive because his macramè hobby website was lost forever when the web host filed for bankruptcy. [more...]