bestwebdesign

Freelancign web design and Graphics design

Thursday 23 November 2017

Forms

HTML Forms

HTML Form Example

First name:

Last name:

The <form> Element

The HTML <form> element defines a form that is used to collect user input<form>


<form>
.
form elements
.
</form>


The <input> Element

he <input> element is the most essential frame element. 

The <input> element can be shown in several courses, contingent upon the sort trait.

some examples:
TypeDescription
<input type="text">Defines a one-line text input field
<input type="radio">Defines a radio button (for selecting one of many choices)
<input type="submit">Defines a submit button (for submitting the form)

Text Input


<input type="text"> defines a one-line input field for text input:

Example:

<form>
  First name:<br>
  <input type="text" name="firstname"><br>
  Last name:<br>
  <input type="text" name="lastname">
</form>
Yourself »

This is how it will look like in a browser:

First name:

Last name:

Radio Button Input

<input type="radio"> defines a radio button.
Radio buttons let a user select ONE of a limited number of choices:

Example

<form>
  <input type="radio" name="gender" value="male" checked> Male<br>
  <input type="radio" name="gender" value="female"> Female<br>
  <input type="radio" name="gender" value="other"> Other
</form>
Yourself »
This is how the HTML code above will be displayed in a browser:
 Male
 Female
 Other

The Submit Button

<input type="submit"> characterizes a catch for presenting the form data to a form-handler. 
The form-handler is ordinarily a server page with a content for preparing input data. 
The form-handler is indicated in the form's activity property:


Example

<form action="/action_page.php">
  First name:<br>
  <input type="text" name="firstname" value="Rasel"><br>
  Last name:<br>
  <input type="text" name="lastname" value="Khan"><br><br>
  <input type="submit" value="Submit">
</form>
Try it Yourself »
This is how the HTML code above will be displayed in a browser:
First name:

First name:

Last name:



The Action Attribute

The action attribute portrays the action to be performed when the edge is submitted. 
Customarily, the shape data is sent to a web page on the server when the customer taps on the submit get. 
For the situation over, the edge data is sent to a page on the server called "/action_page.php". This page contains a server-side substance that handles the shape data:
<form action="/action_page.php">

The Target Attribute


The target attribute determines if the submitted result will open in another program tab, an edge, or in the present window. 

The default esteem is "_self" which implies the shape will be submitted in the present window. 

To influence the frame to come about open in another program tab, utilize the esteem "_blank":

Example

<form action="/action_page.php" target="_blank">
Try it Yourself »

The Method Attribute

The method attribute specifies the HTTP method (GET or POST) to be used when submitting the form data:

Example

<form action="/action_page.php" method="get">
Try it Yourself »

The Name Attribute

Each info field must have a name attribute to be submitted.
On the off chance that the name attribute is precluded, the data of that information field won't be sent by any stretch of the imagination.
This case will just present the "Last name" input field:


Example

<form action="/action_page.php">
  First name:<br>
  <input type="text" value="Mickey"><br>
  Last name:<br>
  <input type="text" name="lastname" value="Mouse"><br><br>
  <input type="submit" value="Submit">
</form>
Try it Yourself »



Grouping Form Data with <fieldset>


The <fieldset> element is used to group related data in a form.

The <legend> element defines a caption for the <fieldset> element.

Example

<form action="/action_page.php">
  <fieldset>
    <legend>Personal information:</legend>
    First name:<br>
    <input type="text" name="firstname" value="Rasel"><br>
    Last name:<br>
    <input type="text" name="lastname" value="Khan"><br><br>
    <input type="submit" value="Submit">
  </fieldset>
</form>
Try it Yourself »

This is how the HTML code above will be displayed in a browser:
Personal information: First name:

Last name:


Share:

0 comments:

Post a Comment


Web Design Tutorial

Theme Support

Munere veritus fierent cu sed, congue altera mea te, ex clita eripuit evertitur duo. Legendos tractatos honestatis ad mel. Legendos tractatos honestatis ad mel. , click here →