Form is used to take data from user and pass it on server.
■ <form> tag is used to create a form.
■ The <form> tag is used for defining the user interface elements , like command buttons , text boxes etc...
■ To pass the data, two attributes of <form> are used-
◉ action= (Required) It defines the name of the file, to which the data will be transferred.
◉ method= (Optional) It defines the method of passing the data.
It may have one of two values-
◆ get- This is the default value. In this method, the query is generated in the address bar and the data will be visible in url. This can be used for non- secure data.
◆ post- In this method, the result is appended to the body of HTTP request and the data will not be visible. This is used for secured data.
Syntax:
<form action= "script url" method= "get|post">
<input>
<input>
<textarea>
.......
.......
</form>
<input>
<input>
<textarea>
.......
.......
</form>
Html Forms Control
1 Text Control:
There are three type of Text Controls:
◆ Single-line Text field
◆ Password field
◆ Multi-line Text field
◆ Single-line Text field
◆ Password field
◆ Multi-line Text field
a) Single Line Text Field:
Syntax:
<input type= "text" name= "any name" />
Example:
<!DOCTYPE html>
<html>
<body>
<form >
Username:<input type="text" name="user_name" />
<br>
Email-id:<input type="text" name="email_id" /><br>
roll:<input type="text" name="roll_id" />
</form>
</body>
</html>
Output:
Username:
Email-id:roll:
b) Password Field:
Syntax:
<input type= "password" name= "any name" />
Example:
1 Open Notepad and copy the below code.
<!DOCTYPE html>
<html>
<body>
<form >
Username:<input type="text" name="user_name" />
<br><br>
Password:<input type="password" name="password" />
</form>
</body>
</html>
save the file .
Output:
Username:
Password:
Password:
c) Multi-line Text field
It is not a type of input element. It is an element itself.
■ <textarea> tag is used for this purpose and this is used in pair.
■ It is a rectangle shaped area to let user input multi line text.
■ <textarea> tag is used for this purpose and this is used in pair.
■ It is a rectangle shaped area to let user input multi line text.
Syntax:
<textarea name= "any name"></textarea>
Example:
1 Open Notepad and paste the code
<!DOCTYPE html>
<html>
<body>
<form >
Address
<br />
<textarea rows="8" cols="30" name="address">
Write Address here........
</textarea>
</form>
</body>
</html>
save the file.
Output:
Address
1 comments:
commentspanu
Reply