SlideShare a Scribd company logo
Lecture 11
In this lecture, we will learn about
    - Using Forms

This topic is very important; actually this topic is the base for web programming. Forms
are used for taking input from the user. After receiving input from the user, that
information is generally stored in database, and for storing information in the database,
either CGI, or ASP, or JSP, or some other scripting language is used. So after this, we can
study ASP also.

So, whatever you will learn in this chapter, will be used later when you will learn ASP.

There is a tag for making forms and it is <form> tag. Like each tag, a form opens by
<form> and closes by <form>. The <form> tag must contain method and action attribute.
Method and action are two important attribute for a <form> tag, there are other attributes
also which are not that important.

The method attribute of <form> tag can be either get or post i.e.
<form method=”get”>
      Or
<form method=”post”>

I will explain the difference between them later on.

Let us discuss about the other attribute first. A Form consists of some input boxes, list
boxes, check boxes so as to accept input from the user. After user enter input, he presses
the submit button, and all the inputs are processed. This statement “all the inputs are
processed”, means that the inputs are generally saved or inputs are used to generate some
information for the user.

For example, if you are searching for a particular book on the internet, you have to fill up
a form. That form may ask you for the name of the book, or the name of author i.e. you
have to provide some input. The input provided by you is then processed, obviously
HTML cannot process the input, and HTML can only accept the input from the user. The
processing of input can be done using only scripting languages, like ASP, or JSP.

So to process the input, this HTML page passes the information to another web page
which is made in ASP or JSP or in some other scripting language. Action attribute of the
<form> tag specified the name of that web page.

So,    <form method=”get” action=”process.asp”>
                   Or
       <form method=”post” action=”process.asp”>

Let us now discuss about form elements i.e. input box, list box, check box etc, which are
used for accepting inputs from the user and we will come back to <form> tag latter.
Forms: input TEXT


The above box is called as a text box; we want a text box like this in our HTML form.
For this, we have a tag

<input type=”text” name=”u_name”>

Let us see how it works, type the following code in notepad and save as a html file.
<html>
        <head>
              <title>Using Form tag-text box</title>
        </head>

       <body>

               <form method="post" action="">
               Enter your name:&nbsp;&nbsp;<input type="text" name="u_name">
               </form>

       </body>
</html>

The output will be
Enter your name:

There is another attribute that can be used with <input type=”text”>, and it is value.
<html>
       <head>
               <title>Using Form tag-text box</title>
       </head>

       <body>

              <form method="post" action="">
              Enter your name:&nbsp;&nbsp;<input type="text" name="u_name"
value="Harshit">
              </form>

       </body>
</html>



The output will be
Enter your name:


If you want the user should be able to enter password, and that password appears as ‘*’
the screen, then

<input type=”password” name=”u_pass”>

Type the following code
<html>
       <head>
              <title>Using Form tag-text box</title>
       </head>

       <body>

              <form method="post" action="">
              Enter your name:&nbsp;&nbsp;<input type="text" name="u_name"
value="Harshit"> <br>
              Enter your password:&nbsp;&nbsp; <input type="password"
name="u_pass">
              </form>

       </body>
</html>

And the output is

Enter your name:
Enter your password:



There are two more attributes of the <input> tag, size and maxlength. Size attribute
defines the initial width of the control, and maxlength attribute specifies the maximum
number of character a user can enter.

For example:
Type the following code in notepad and save as .html
<html>
       <head>
              <title>Using Form tag-text box</title>
       </head>

       <body>
<form method="post" action="">
              Enter your name:&nbsp;&nbsp;<input type="text" name="u_name"
value="Harshit" maxlength="10"> <br>
              Enter your password:&nbsp;&nbsp; <input type="password"
name="u_pass">
              </form>

       </body>
</html>

Forms: additional input types
       There are other input types that can be used with < input type= >. We have used
type=text/password.
Type can also be used as <input type=checkbox/radio/image/submit/button/hidden>.

Let us take an example for each type, and try to understand this.
Type the following code which is for checkbox.

<html>
         <head>
               <title>Using Form tag-text box</title>
         </head>

         <body>

                <form method="post" action="">
                       Which fruit do you like? <br>
                <input type="checkbox" name="fruit" value="apple"> Apple <br>
                <input type="checkbox" name="fruit" value="Mango"> mango <br>
                       <input type="checkbox" name="fruit" value="Orange"> Orange
<br>
                </form>

       </body>
</html>

The output is
Which fruit do you like?
Apple
mango
Orange


Notice that in the above code,
   • type=”checkbox”.
•     All the input tag has a common name, i.e. name=”fruit”. You can give any name,
         but name should be common for all the checkboxes

If you think that most people like apples, you can pre-select it, some thing like this.
<input type="checkbox" name="fruits" value=”apple” checked> Apples<br>

Type the following code,
<html>
       <head>
              <title>Using Form tag-text box</title>
       </head>

         <body>

             <form method="post" action="">
                    Which fruit do you like? <br>
                          <input type="checkbox" name="fruit" value="apple"
checked> Apple <br>
                          <input type="checkbox" name="fruit" value="Mango">
mango <br>
                          <input type="checkbox" name="fruit" value="Orange">
Orange <br>
             </form>

       </body>
</html>

And the output is
Which fruit do you like?
Apple
mango
Orange

Radio buttons are sets of circle-like selectors in which the user may only make one
choice. The only difference between radio button and check box is number of selections.
With checkbox user can select more than one option but with the radio button, use can
only select one option.

The above code with radio button is like this.

<html>
         <head>
               <title>Using Form tag-text box</title>
         </head>

         <body>
<form method="post" action="">
                     Which fruit do you like? <br>
                           <input type="radio" name="fruit" value="apple"> Apple
<br>
                               <input type="radio" name="fruit" value="Mango"> mango
<br>
                               <input type="radio" name="fruit" value="Orange">
Orange <br>
               </form>

       </body>
</html>


The output is
Which fruit do you like?
Apple
mango
Orange

Notice that
   • Type=”radio”
   • All the input tag has a common name “radio”.

We will discuss later on about type=”image/button/submit/hidden”

Forms: textarea and option/select
<textarea> tag allows the user to enter multiple lines of text. It also has an opening and
closing tag, like most of the form elements. It is used as follows

<textarea name=”u_text” rows=”4” cols=”10” wrap=”virtual>,

I think only one thing needs explanation here, and it is wrap, wrap=”virtual” means if
user types any thing, the text should not go beyond the right side of the box.

Type the following code to understand more about <textarea>
<html>
       <head>
              <title>Using Form tag-TextArea</title>
       </head>

       <body>

               <form method="post" action="">
               Write a short note about urself<br>
<textarea name=”u_text” rows=”4” cols=”10”
wrap=”virtual>If you write something here, it will appear in the browser also.
                             </textarea>
              </form>

       </body>
</html>


Write a short note about urself


Anything you include between the opening and closing textarea tags will appear in the
textarea box.


The <select> element works a lot like a radio button, except in that it used a cool drop
down box. It also has a closing tag, </select>. Choices for the drop down box are
created by using <option> tags.

 <select name="fav">
<option value="apples">apples</option>
<option value="oranges">oranges</option>
<option value="bananas">bananas</option>
</select>

Which fruit is your favorite?



Now let us put all this into one form, and then complete this lecture.

   <html>
            <head>
                  <title>Using Form tag-text box</title>
            </head>

            <body>

                   <form method="post" action="">

   Enter your name:&nbsp;&nbsp;<input type="text" name="u_name"
   value="Harshit"> <br>

   Enter your password:&nbsp;&nbsp; <input type="password" name="u_pass"><br>
Write a short note about urself<br>
   <textarea name=”u_text” rows=”4” cols=”10” wrap=”virtual>If you write something
   here, that will appear in the

   browser also.
   </textarea><br>

   Which fruit do you like? <br>
                 <input type="checkbox" name="fruit" value="apple"> Apple <br>
                 <input type="checkbox" name="fruit" value="Mango"> mango <br>
                 <input type="checkbox" name="fruit" value="Orange"> Orange <br>

   Which fruit do you like? <br>
                                <input type="radio" name="fruit" value="apple">
   Apple <br>
                                <input type="radio" name="fruit" value="Mango">
   mango <br>
                                <input type="radio" name="fruit" value="Orange">
   Orange <br>


   <select name="fav">
   <option value="apples">apples</option>
   <option value="oranges">oranges</option>
   <option value="bananas">bananas</option>
   </select>

                   </form>

          </body>
   </html>



The output will be
Enter your name:
Enter your password:
Write a short note about urself

Which fruit do you like?
Apple
mango
Orange
Which fruit do you like?
Apple
mango
Orange


So, user will provide input, but after providing input he has to submit the input, for
submitting input, we need a button.

So, next topic is How to make a button in HTML page. Very simple, tag for that is
<input type = submit name=”sub_b” >

Insert the line in the above code, and the output will be

Enter your name:
Enter your password:
Write a short note about urself

Which fruit do you like?
Apple
mango
Orange
Which fruit do you like?
Apple
mango
Orange




If you click on the submit button, all the inputs will be passed to the page specified in
action attribute of form tag. This topic we will discuss later when we will discuss ASP.

More Related Content

What's hot (20)

PDF
An Seo’s Intro to Web Dev, HTML, CSS and JavaScript
Troyfawkes
 
PDF
An SEO’s Intro to Web Dev PHP
Troyfawkes
 
PPTX
Html form tag
shreyachougule
 
PPT
Web pageassignment
beachtch
 
PDF
Html basics
Vjay Vijju
 
PDF
5.1 html lec 5
IoT Code Lab
 
PDF
4.1 html lec 4
IoT Code Lab
 
PPT
Introduction html
Mayank Saxena
 
PPTX
Html basics
php Roots
 
PPTX
HTML Forms Tutorial
ProdigyView
 
PDF
HTML practical guide for O/L exam
Anne Perera
 
PPTX
Html tables, forms and audio video
Saad Sheikh
 
PPTX
Forms in html5
hrisi87
 
PPTX
HTML Forms
Nisa Soomro
 
PDF
Introhtml 2
bluejayjunior
 
PPTX
Web engineering - HTML Form
Nosheen Qamar
 
PPT
Html
Bhumika Ratan
 
PDF
Getting Information through HTML Forms
Mike Crabb
 
PDF
Html full
GulshanKumar368
 
PPTX
html tutorial
pacatarpit
 
An Seo’s Intro to Web Dev, HTML, CSS and JavaScript
Troyfawkes
 
An SEO’s Intro to Web Dev PHP
Troyfawkes
 
Html form tag
shreyachougule
 
Web pageassignment
beachtch
 
Html basics
Vjay Vijju
 
5.1 html lec 5
IoT Code Lab
 
4.1 html lec 4
IoT Code Lab
 
Introduction html
Mayank Saxena
 
Html basics
php Roots
 
HTML Forms Tutorial
ProdigyView
 
HTML practical guide for O/L exam
Anne Perera
 
Html tables, forms and audio video
Saad Sheikh
 
Forms in html5
hrisi87
 
HTML Forms
Nisa Soomro
 
Introhtml 2
bluejayjunior
 
Web engineering - HTML Form
Nosheen Qamar
 
Getting Information through HTML Forms
Mike Crabb
 
Html full
GulshanKumar368
 
html tutorial
pacatarpit
 

Similar to Html basics 10 form (20)

PPTX
Designing web pages html forms and input
Jesus Obenita Jr.
 
PDF
Html advanced-reference-guide for creating web forms
satish 486
 
PDF
WEB DESIGN AND INTERNET PROGRAMMING LAB MANUAL.pdf
mmgg1621
 
PDF
web technology practical file
FreedomFox1
 
PPTX
HTML FORMS.pptx
Sierranaijamusic
 
PPTX
HTML - hypertext markup language
Basmaa Mostafa
 
PPT
05 html-forms
Palakshya
 
DOCX
Tercer trabajo de drapi 02
Jhon Silva Penekita
 
PPTX
HNDIT1022 Week 03 Part 2 Theory information.pptx
IsuriUmayangana
 
PDF
HSC INFORMATION TECHNOLOGY CHAPTER 1 ADVANCED WEB DESIGNING PART III.pdf
AAFREEN SHAIKH
 
DOCX
Php forms and validations by naveen kumar veligeti
Naveen Kumar Veligeti
 
PPTX
Html form
Jaya Kumari
 
PPT
Spsl v unit - final
Sasidhar Kothuru
 
DOCX
Html forms
Abhishek Kesharwani
 
PPTX
Unit - III.pptxbgffhjxfjdfjfgjnsnsnshdhsjsksjsjsjsjsjsjsjsjsldksk
cpbloger553
 
PPTX
Unit - III.pptxbgffhjxfjdfjfgjnsnsnshdhsjsksjsjsjsjsjsjsjsjsldksk
cpbloger553
 
PPT
Component and Event-Driven Architectures in PHP
Stephan Schmidt
 
Designing web pages html forms and input
Jesus Obenita Jr.
 
Html advanced-reference-guide for creating web forms
satish 486
 
WEB DESIGN AND INTERNET PROGRAMMING LAB MANUAL.pdf
mmgg1621
 
web technology practical file
FreedomFox1
 
HTML FORMS.pptx
Sierranaijamusic
 
HTML - hypertext markup language
Basmaa Mostafa
 
05 html-forms
Palakshya
 
Tercer trabajo de drapi 02
Jhon Silva Penekita
 
HNDIT1022 Week 03 Part 2 Theory information.pptx
IsuriUmayangana
 
HSC INFORMATION TECHNOLOGY CHAPTER 1 ADVANCED WEB DESIGNING PART III.pdf
AAFREEN SHAIKH
 
Php forms and validations by naveen kumar veligeti
Naveen Kumar Veligeti
 
Html form
Jaya Kumari
 
Spsl v unit - final
Sasidhar Kothuru
 
Unit - III.pptxbgffhjxfjdfjfgjnsnsnshdhsjsksjsjsjsjsjsjsjsjsldksk
cpbloger553
 
Unit - III.pptxbgffhjxfjdfjfgjnsnsnshdhsjsksjsjsjsjsjsjsjsjsldksk
cpbloger553
 
Component and Event-Driven Architectures in PHP
Stephan Schmidt
 
Ad

More from H K (20)

PDF
Assignment4
H K
 
DOCX
Assignment3
H K
 
PDF
Induction
H K
 
PDF
Solution3
H K
 
PDF
Solution2
H K
 
DOCX
Mid-
H K
 
PDF
Assignment4
H K
 
PDF
Assignment4
H K
 
PDF
Dm assignment3
H K
 
PPT
Proof
H K
 
PDF
Resolution
H K
 
DOCX
Assignment description
H K
 
PDF
Dm assignment2
H K
 
PDF
Set
H K
 
PDF
Dm assignment1
H K
 
PPTX
Logic
H K
 
DOCX
Introduction
H K
 
PDF
Assignment 2 sol
H K
 
PDF
Assignment sw solution
H K
 
PDF
Violinphoenix
H K
 
Assignment4
H K
 
Assignment3
H K
 
Induction
H K
 
Solution3
H K
 
Solution2
H K
 
Mid-
H K
 
Assignment4
H K
 
Assignment4
H K
 
Dm assignment3
H K
 
Proof
H K
 
Resolution
H K
 
Assignment description
H K
 
Dm assignment2
H K
 
Set
H K
 
Dm assignment1
H K
 
Logic
H K
 
Introduction
H K
 
Assignment 2 sol
H K
 
Assignment sw solution
H K
 
Violinphoenix
H K
 
Ad

Recently uploaded (20)

PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Dimensions of Societal Planning in Commonism
StefanMz
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 

Html basics 10 form

  • 1. Lecture 11 In this lecture, we will learn about - Using Forms This topic is very important; actually this topic is the base for web programming. Forms are used for taking input from the user. After receiving input from the user, that information is generally stored in database, and for storing information in the database, either CGI, or ASP, or JSP, or some other scripting language is used. So after this, we can study ASP also. So, whatever you will learn in this chapter, will be used later when you will learn ASP. There is a tag for making forms and it is <form> tag. Like each tag, a form opens by <form> and closes by <form>. The <form> tag must contain method and action attribute. Method and action are two important attribute for a <form> tag, there are other attributes also which are not that important. The method attribute of <form> tag can be either get or post i.e. <form method=”get”> Or <form method=”post”> I will explain the difference between them later on. Let us discuss about the other attribute first. A Form consists of some input boxes, list boxes, check boxes so as to accept input from the user. After user enter input, he presses the submit button, and all the inputs are processed. This statement “all the inputs are processed”, means that the inputs are generally saved or inputs are used to generate some information for the user. For example, if you are searching for a particular book on the internet, you have to fill up a form. That form may ask you for the name of the book, or the name of author i.e. you have to provide some input. The input provided by you is then processed, obviously HTML cannot process the input, and HTML can only accept the input from the user. The processing of input can be done using only scripting languages, like ASP, or JSP. So to process the input, this HTML page passes the information to another web page which is made in ASP or JSP or in some other scripting language. Action attribute of the <form> tag specified the name of that web page. So, <form method=”get” action=”process.asp”> Or <form method=”post” action=”process.asp”> Let us now discuss about form elements i.e. input box, list box, check box etc, which are used for accepting inputs from the user and we will come back to <form> tag latter.
  • 2. Forms: input TEXT The above box is called as a text box; we want a text box like this in our HTML form. For this, we have a tag <input type=”text” name=”u_name”> Let us see how it works, type the following code in notepad and save as a html file. <html> <head> <title>Using Form tag-text box</title> </head> <body> <form method="post" action=""> Enter your name:&nbsp;&nbsp;<input type="text" name="u_name"> </form> </body> </html> The output will be Enter your name: There is another attribute that can be used with <input type=”text”>, and it is value. <html> <head> <title>Using Form tag-text box</title> </head> <body> <form method="post" action=""> Enter your name:&nbsp;&nbsp;<input type="text" name="u_name" value="Harshit"> </form> </body> </html> The output will be
  • 3. Enter your name: If you want the user should be able to enter password, and that password appears as ‘*’ the screen, then <input type=”password” name=”u_pass”> Type the following code <html> <head> <title>Using Form tag-text box</title> </head> <body> <form method="post" action=""> Enter your name:&nbsp;&nbsp;<input type="text" name="u_name" value="Harshit"> <br> Enter your password:&nbsp;&nbsp; <input type="password" name="u_pass"> </form> </body> </html> And the output is Enter your name: Enter your password: There are two more attributes of the <input> tag, size and maxlength. Size attribute defines the initial width of the control, and maxlength attribute specifies the maximum number of character a user can enter. For example: Type the following code in notepad and save as .html <html> <head> <title>Using Form tag-text box</title> </head> <body>
  • 4. <form method="post" action=""> Enter your name:&nbsp;&nbsp;<input type="text" name="u_name" value="Harshit" maxlength="10"> <br> Enter your password:&nbsp;&nbsp; <input type="password" name="u_pass"> </form> </body> </html> Forms: additional input types There are other input types that can be used with < input type= >. We have used type=text/password. Type can also be used as <input type=checkbox/radio/image/submit/button/hidden>. Let us take an example for each type, and try to understand this. Type the following code which is for checkbox. <html> <head> <title>Using Form tag-text box</title> </head> <body> <form method="post" action=""> Which fruit do you like? <br> <input type="checkbox" name="fruit" value="apple"> Apple <br> <input type="checkbox" name="fruit" value="Mango"> mango <br> <input type="checkbox" name="fruit" value="Orange"> Orange <br> </form> </body> </html> The output is Which fruit do you like? Apple mango Orange Notice that in the above code, • type=”checkbox”.
  • 5. All the input tag has a common name, i.e. name=”fruit”. You can give any name, but name should be common for all the checkboxes If you think that most people like apples, you can pre-select it, some thing like this. <input type="checkbox" name="fruits" value=”apple” checked> Apples<br> Type the following code, <html> <head> <title>Using Form tag-text box</title> </head> <body> <form method="post" action=""> Which fruit do you like? <br> <input type="checkbox" name="fruit" value="apple" checked> Apple <br> <input type="checkbox" name="fruit" value="Mango"> mango <br> <input type="checkbox" name="fruit" value="Orange"> Orange <br> </form> </body> </html> And the output is Which fruit do you like? Apple mango Orange Radio buttons are sets of circle-like selectors in which the user may only make one choice. The only difference between radio button and check box is number of selections. With checkbox user can select more than one option but with the radio button, use can only select one option. The above code with radio button is like this. <html> <head> <title>Using Form tag-text box</title> </head> <body>
  • 6. <form method="post" action=""> Which fruit do you like? <br> <input type="radio" name="fruit" value="apple"> Apple <br> <input type="radio" name="fruit" value="Mango"> mango <br> <input type="radio" name="fruit" value="Orange"> Orange <br> </form> </body> </html> The output is Which fruit do you like? Apple mango Orange Notice that • Type=”radio” • All the input tag has a common name “radio”. We will discuss later on about type=”image/button/submit/hidden” Forms: textarea and option/select <textarea> tag allows the user to enter multiple lines of text. It also has an opening and closing tag, like most of the form elements. It is used as follows <textarea name=”u_text” rows=”4” cols=”10” wrap=”virtual>, I think only one thing needs explanation here, and it is wrap, wrap=”virtual” means if user types any thing, the text should not go beyond the right side of the box. Type the following code to understand more about <textarea> <html> <head> <title>Using Form tag-TextArea</title> </head> <body> <form method="post" action=""> Write a short note about urself<br>
  • 7. <textarea name=”u_text” rows=”4” cols=”10” wrap=”virtual>If you write something here, it will appear in the browser also. </textarea> </form> </body> </html> Write a short note about urself Anything you include between the opening and closing textarea tags will appear in the textarea box. The <select> element works a lot like a radio button, except in that it used a cool drop down box. It also has a closing tag, </select>. Choices for the drop down box are created by using <option> tags. <select name="fav"> <option value="apples">apples</option> <option value="oranges">oranges</option> <option value="bananas">bananas</option> </select> Which fruit is your favorite? Now let us put all this into one form, and then complete this lecture. <html> <head> <title>Using Form tag-text box</title> </head> <body> <form method="post" action=""> Enter your name:&nbsp;&nbsp;<input type="text" name="u_name" value="Harshit"> <br> Enter your password:&nbsp;&nbsp; <input type="password" name="u_pass"><br>
  • 8. Write a short note about urself<br> <textarea name=”u_text” rows=”4” cols=”10” wrap=”virtual>If you write something here, that will appear in the browser also. </textarea><br> Which fruit do you like? <br> <input type="checkbox" name="fruit" value="apple"> Apple <br> <input type="checkbox" name="fruit" value="Mango"> mango <br> <input type="checkbox" name="fruit" value="Orange"> Orange <br> Which fruit do you like? <br> <input type="radio" name="fruit" value="apple"> Apple <br> <input type="radio" name="fruit" value="Mango"> mango <br> <input type="radio" name="fruit" value="Orange"> Orange <br> <select name="fav"> <option value="apples">apples</option> <option value="oranges">oranges</option> <option value="bananas">bananas</option> </select> </form> </body> </html> The output will be Enter your name: Enter your password: Write a short note about urself Which fruit do you like? Apple mango Orange Which fruit do you like? Apple mango
  • 9. Orange So, user will provide input, but after providing input he has to submit the input, for submitting input, we need a button. So, next topic is How to make a button in HTML page. Very simple, tag for that is <input type = submit name=”sub_b” > Insert the line in the above code, and the output will be Enter your name: Enter your password: Write a short note about urself Which fruit do you like? Apple mango Orange Which fruit do you like? Apple mango Orange If you click on the submit button, all the inputs will be passed to the page specified in action attribute of form tag. This topic we will discuss later when we will discuss ASP.