SlideShare a Scribd company logo
Theory and examples
28-Jun-14
What are forms?
 <form> is just another kind of HTML tag
 HTML forms are used to create (rather primitive) GUIs on Web
pages
 Usually the purpose is to ask the user for information
 The information is then sent back to the server
 A form is an area that can contain form elements
 The syntax is: <form parameters> ...form elements... </form>
 Form elements include: buttons, checkboxes, text fields, radio buttons,
drop-down menus, etc
 Other kinds of HTML tags can be mixed in with the form elements
 A form usually contains a Submit button to send the information in he
form elements to the server
 The form’s parameters tell JavaScript how to send the information to
the server (there are two different ways it could be sent)
 Forms can be used for other things, such as a GUI for simple programs
2
Forms and JavaScript
 The JavaScript language can be used to make pages that “do
something”
 You can use JavaScript to write complete programs, but...
 Usually you just use snippets of JavaScript here and there
throughout your Web page
 JavaScript code snippets can be attached to various form elements
 For example, you might want to check that a zipcode field contains a 5-
digit integer before you send that information to the server
 Microsoft sometimes calls JavaScript “active scripting”
 HTML forms can be used without JavaScript, and
JavaScript can be used without HTML forms, but they work
well together
 JavaScript for HTML is covered in a separate lecture
3
The <form> tag
 The <form arguments> ... </form> tag encloses form
elements (and probably other HTML as well)
 The arguments to form tell what to do with the user
input
 action="url" (required)
 Specifies where to send the data when the Submit button is clicked
 method="get" (default)
 Form data is sent as a URL with ?form_data info appended to the end
 Can be used only if data is all ASCII and not more than 100 characters
 method="post"
 Form data is sent in the body of the URL request
 Cannot be bookmarked by most browsers
 target="target"
 Tells where to open the page sent as a result of the request
 target= _blank means open in a new window
 target= _top means use the same window
4
The <input> tag
 Most, but not all, form elements use the input tag, with a
type="..." argument to tell which kind of element it is
 type can be text, checkbox, radio, password, hidden, submit,
reset, button, file, or image
 Other common input tag arguments include:
 name: the name of the element
 value: the “value” of the element; used in different ways for
different values of type
 readonly: the value cannot be changed
 disabled: the user can’t do anything with this element
 Other arguments are defined for the input tag but have meaning
only for certain values of type
5
Text input
6
A text field:
<input type="text" name="textfield" value="with an initial value">
A multi-line text field
<textarea name="textarea" cols="24" rows="2">Hello</textarea>
A password field:
<input type="password" name="textfield3" value="secret">
• Note that two of these use the input tag, but one uses textarea
Buttons
 A submit button:
<input type="submit" name="Submit" value="Submit">
 A reset button:
<input type="reset" name="Submit2" value="Reset">
 A plain button:
<input type="button" name="Submit3" value="Push Me">
 submit: send data
 reset: restore all form elements to their
initial state
 button: take some action as specified by
JavaScript
7
• Note that the type is input, not “button”
Checkboxes
 A checkbox:
<input type="checkbox" name="checkbox”
value="checkbox" checked>
 type: "checkbox"
 name: used to reference this form element from JavaScript
 value: value to be returned when element is checked
 Note that there is no text associated with the checkbox—you
have to supply text in the surrounding HTML
8
Radio buttons
Radio buttons:<br>
<input type="radio" name="radiobutton" value="myValue1">
male<br>
<input type="radio" name="radiobutton" value="myValue2" checked>
female
 If two or more radio buttons have the same name, the user
can only select one of them at a time
 This is how you make a radio button “group”
 If you ask for the value of that name, you will get the value
specified for the selected radio button
 As with checkboxes, radio buttons do not contain any text
9
Drop-down menu or list
 A menu or list:
<select name="select">
<option value="red">red</option>
<option value="green">green</option>
<option value="BLUE">blue</option>
</select>
 Additional arguments:
 size: the number of items visible in the list (default is "1")
 multiple: if set to "true", any number of items may be selected
(default is "false")
10
Hidden fields
 <input type="hidden" name="hiddenField" value="nyah">
&lt;-- right there, don't you see it?
 What good is this?
 All input fields are sent back to the server, including hidden fields
 This is a way to include information that the user doesn’t need to see
(or that you don’t want her to see)
 The value of a hidden field can be set programmatically (by JavaScript)
before the form is submitted
11
A complete example<html>
<head>
<title>Get Identity</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<p><b>Who are you?</b></p>
<form method="post" action="">
<p>Name:
<input type="text" name="textfield">
</p>
<p>Gender:
<input type="radio" name="gender" value="m">Male
<input type="radio" name="gender" value="f">Female</p>
</form>
</body>
</html>
12

More Related Content

What's hot

HTML5 audio & video
HTML5 audio & videoHTML5 audio & video
HTML5 audio & video
Hamza Zahid
 
Javascript arrays
Javascript arraysJavascript arrays
Javascript arrays
Hassan Dar
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
Bala Narayanan
 
Javascript
JavascriptJavascript
Javascript
Manav Prasad
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
Partnered Health
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
Sehwan Noh
 
Html table tags
Html table tagsHtml table tags
Html table tags
eShikshak
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
Amit Tyagi
 
Css
CssCss
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy
 
Web html table tags
Web html  table tagsWeb html  table tags
Web html table tags
Kainat Ilyas
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypesVarun C M
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
Html forms
Html formsHtml forms
Html forms
nobel mujuji
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Andres Baravalle
 
Java script
Java scriptJava script
Java script
Shyam Khant
 
Functions in javascript
Functions in javascriptFunctions in javascript

What's hot (20)

HTML5 audio & video
HTML5 audio & videoHTML5 audio & video
HTML5 audio & video
 
Javascript arrays
Javascript arraysJavascript arrays
Javascript arrays
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
Javascript
JavascriptJavascript
Javascript
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
Css Ppt
Css PptCss Ppt
Css Ppt
 
Html table tags
Html table tagsHtml table tags
Html table tags
 
Html
HtmlHtml
Html
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Css
CssCss
Css
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
Web html table tags
Web html  table tagsWeb html  table tags
Web html table tags
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Html forms
Html formsHtml forms
Html forms
 
Dom
DomDom
Dom
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Java script
Java scriptJava script
Java script
 
Functions in javascript
Functions in javascriptFunctions in javascript
Functions in javascript
 

Viewers also liked

Html forms
Html formsHtml forms
Html forms
eShikshak
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
Nisa Soomro
 
Tables and Forms in HTML
Tables and Forms in HTMLTables and Forms in HTML
Tables and Forms in HTMLDoncho Minkov
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
www.netgains.org
 
Table and Form HTML&CSS
Table and Form HTML&CSSTable and Form HTML&CSS
Table and Form HTML&CSS
Yaowaluck Promdee
 
Tables and Forms in HTML
Tables and Forms in HTMLTables and Forms in HTML
Tables and Forms in HTML
Marlon Jamera
 
Open Source and Open Data in the Age of the Cloud
Open Source and Open Data in the Age of the CloudOpen Source and Open Data in the Age of the Cloud
Open Source and Open Data in the Age of the Cloud
Tim O'Reilly
 
Session and cookies ,get and post methods
Session and cookies ,get and post methodsSession and cookies ,get and post methods
Session and cookies ,get and post methods
baabtra.com - No. 1 supplier of quality freshers
 
CSS Animations & Transitions
CSS Animations & TransitionsCSS Animations & Transitions
CSS Animations & Transitions
Edward Meehan
 
CSS3 Transforms Transitions and Animations
CSS3 Transforms Transitions and AnimationsCSS3 Transforms Transitions and Animations
CSS3 Transforms Transitions and Animations
Inayaili León
 
Creating Beautiful CSS3 Animations - FITC Amsterdam 2016
Creating Beautiful CSS3 Animations - FITC Amsterdam 2016Creating Beautiful CSS3 Animations - FITC Amsterdam 2016
Creating Beautiful CSS3 Animations - FITC Amsterdam 2016
Rami Sayar
 
CSS Tutorial
CSS TutorialCSS Tutorial
Fundamental HTML5
Fundamental HTML5Fundamental HTML5
Fundamental HTML5
Achmad Solichin
 
CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations
Rob LaPlaca
 
Html tables, forms and audio video
Html tables, forms and audio videoHtml tables, forms and audio video
Html tables, forms and audio video
Saad Sheikh
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3
Doris Chen
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
WordPress Memphis
 
PHP & MySQL 教學
PHP & MySQL 教學PHP & MySQL 教學
PHP & MySQL 教學
Bo-Yi Wu
 
Architecture of the Web browser
Architecture of the Web browserArchitecture of the Web browser
Architecture of the Web browser
Sabin Buraga
 

Viewers also liked (20)

Html forms
Html formsHtml forms
Html forms
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
Tables and Forms in HTML
Tables and Forms in HTMLTables and Forms in HTML
Tables and Forms in HTML
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
 
Table and Form HTML&CSS
Table and Form HTML&CSSTable and Form HTML&CSS
Table and Form HTML&CSS
 
Tables and Forms in HTML
Tables and Forms in HTMLTables and Forms in HTML
Tables and Forms in HTML
 
Open Source and Open Data in the Age of the Cloud
Open Source and Open Data in the Age of the CloudOpen Source and Open Data in the Age of the Cloud
Open Source and Open Data in the Age of the Cloud
 
Session and cookies ,get and post methods
Session and cookies ,get and post methodsSession and cookies ,get and post methods
Session and cookies ,get and post methods
 
CSS Animations & Transitions
CSS Animations & TransitionsCSS Animations & Transitions
CSS Animations & Transitions
 
CSS3 Transforms Transitions and Animations
CSS3 Transforms Transitions and AnimationsCSS3 Transforms Transitions and Animations
CSS3 Transforms Transitions and Animations
 
Basic css-tutorial
Basic css-tutorialBasic css-tutorial
Basic css-tutorial
 
Creating Beautiful CSS3 Animations - FITC Amsterdam 2016
Creating Beautiful CSS3 Animations - FITC Amsterdam 2016Creating Beautiful CSS3 Animations - FITC Amsterdam 2016
Creating Beautiful CSS3 Animations - FITC Amsterdam 2016
 
CSS Tutorial
CSS TutorialCSS Tutorial
CSS Tutorial
 
Fundamental HTML5
Fundamental HTML5Fundamental HTML5
Fundamental HTML5
 
CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations
 
Html tables, forms and audio video
Html tables, forms and audio videoHtml tables, forms and audio video
Html tables, forms and audio video
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
PHP & MySQL 教學
PHP & MySQL 教學PHP & MySQL 教學
PHP & MySQL 教學
 
Architecture of the Web browser
Architecture of the Web browserArchitecture of the Web browser
Architecture of the Web browser
 

Similar to 2. HTML forms

html forms
html formshtml forms
html forms
ikram niaz
 
20-html-forms.ppt
20-html-forms.ppt20-html-forms.ppt
20-html-forms.ppt
KarenCato1
 
11-html-forms.ppt
11-html-forms.ppt11-html-forms.ppt
11-html-forms.ppt
karansingh4126
 
HtmlForms- basic HTML forms description.
HtmlForms- basic HTML forms description.HtmlForms- basic HTML forms description.
HtmlForms- basic HTML forms description.
MohammadRafsunIslam
 
20 html-forms
20 html-forms20 html-forms
20 html-formsKumar
 
05 html-forms
05 html-forms05 html-forms
05 html-formsPalakshya
 
Web forms and html lecture Number 4
Web forms and html lecture Number 4Web forms and html lecture Number 4
Web forms and html lecture Number 4
Mudasir Syed
 
Html,Css and Javascript Forms using different tags
Html,Css and Javascript Forms using different tagsHtml,Css and Javascript Forms using different tags
Html,Css and Javascript Forms using different tags
JeirahTigas
 
Html Forms.ppt
Html Forms.pptHtml Forms.ppt
Html Forms.ppt
MAHASWETAMANDAL1
 
8741aad2f359a5ee62afdf4cc4341440 (1) (1) (1).pdf
8741aad2f359a5ee62afdf4cc4341440 (1) (1) (1).pdf8741aad2f359a5ee62afdf4cc4341440 (1) (1) (1).pdf
8741aad2f359a5ee62afdf4cc4341440 (1) (1) (1).pdf
BHSJangir
 
Designing web pages html forms and input
Designing web pages html  forms and inputDesigning web pages html  forms and input
Designing web pages html forms and inputJesus Obenita Jr.
 
Html Form Controls
Html Form ControlsHtml Form Controls
HTML 5 Simple Tutorial Part 4
HTML 5 Simple Tutorial Part 4HTML 5 Simple Tutorial Part 4
HTML 5 Simple Tutorial Part 4
Sanjeev Kumar
 
CSS_Forms.pdf
CSS_Forms.pdfCSS_Forms.pdf
CSS_Forms.pdf
gunjansingh599205
 
Web topic 20 1 html forms
Web topic 20 1  html formsWeb topic 20 1  html forms
Web topic 20 1 html formsCK Yang
 
Web topic 20 2 html forms
Web topic 20 2  html formsWeb topic 20 2  html forms
Web topic 20 2 html formsCK Yang
 
Web design - Working with forms in HTML
Web design - Working with forms in HTMLWeb design - Working with forms in HTML
Web design - Working with forms in HTML
Mustafa Kamel Mohammadi
 

Similar to 2. HTML forms (20)

html forms
html formshtml forms
html forms
 
20-html-forms.ppt
20-html-forms.ppt20-html-forms.ppt
20-html-forms.ppt
 
11-html-forms.ppt
11-html-forms.ppt11-html-forms.ppt
11-html-forms.ppt
 
HtmlForms- basic HTML forms description.
HtmlForms- basic HTML forms description.HtmlForms- basic HTML forms description.
HtmlForms- basic HTML forms description.
 
20 html-forms
20 html-forms20 html-forms
20 html-forms
 
Html class-04
Html class-04Html class-04
Html class-04
 
05 html-forms
05 html-forms05 html-forms
05 html-forms
 
HTML
HTML HTML
HTML
 
Web forms and html lecture Number 4
Web forms and html lecture Number 4Web forms and html lecture Number 4
Web forms and html lecture Number 4
 
Html,Css and Javascript Forms using different tags
Html,Css and Javascript Forms using different tagsHtml,Css and Javascript Forms using different tags
Html,Css and Javascript Forms using different tags
 
Html Forms.ppt
Html Forms.pptHtml Forms.ppt
Html Forms.ppt
 
8741aad2f359a5ee62afdf4cc4341440 (1) (1) (1).pdf
8741aad2f359a5ee62afdf4cc4341440 (1) (1) (1).pdf8741aad2f359a5ee62afdf4cc4341440 (1) (1) (1).pdf
8741aad2f359a5ee62afdf4cc4341440 (1) (1) (1).pdf
 
Designing web pages html forms and input
Designing web pages html  forms and inputDesigning web pages html  forms and input
Designing web pages html forms and input
 
Html Form Controls
Html Form ControlsHtml Form Controls
Html Form Controls
 
Html forms
Html formsHtml forms
Html forms
 
HTML 5 Simple Tutorial Part 4
HTML 5 Simple Tutorial Part 4HTML 5 Simple Tutorial Part 4
HTML 5 Simple Tutorial Part 4
 
CSS_Forms.pdf
CSS_Forms.pdfCSS_Forms.pdf
CSS_Forms.pdf
 
Web topic 20 1 html forms
Web topic 20 1  html formsWeb topic 20 1  html forms
Web topic 20 1 html forms
 
Web topic 20 2 html forms
Web topic 20 2  html formsWeb topic 20 2  html forms
Web topic 20 2 html forms
 
Web design - Working with forms in HTML
Web design - Working with forms in HTMLWeb design - Working with forms in HTML
Web design - Working with forms in HTML
 

Recently uploaded

Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
Sharepoint Designs
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 

Recently uploaded (20)

Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 

2. HTML forms

  • 2. What are forms?  <form> is just another kind of HTML tag  HTML forms are used to create (rather primitive) GUIs on Web pages  Usually the purpose is to ask the user for information  The information is then sent back to the server  A form is an area that can contain form elements  The syntax is: <form parameters> ...form elements... </form>  Form elements include: buttons, checkboxes, text fields, radio buttons, drop-down menus, etc  Other kinds of HTML tags can be mixed in with the form elements  A form usually contains a Submit button to send the information in he form elements to the server  The form’s parameters tell JavaScript how to send the information to the server (there are two different ways it could be sent)  Forms can be used for other things, such as a GUI for simple programs 2
  • 3. Forms and JavaScript  The JavaScript language can be used to make pages that “do something”  You can use JavaScript to write complete programs, but...  Usually you just use snippets of JavaScript here and there throughout your Web page  JavaScript code snippets can be attached to various form elements  For example, you might want to check that a zipcode field contains a 5- digit integer before you send that information to the server  Microsoft sometimes calls JavaScript “active scripting”  HTML forms can be used without JavaScript, and JavaScript can be used without HTML forms, but they work well together  JavaScript for HTML is covered in a separate lecture 3
  • 4. The <form> tag  The <form arguments> ... </form> tag encloses form elements (and probably other HTML as well)  The arguments to form tell what to do with the user input  action="url" (required)  Specifies where to send the data when the Submit button is clicked  method="get" (default)  Form data is sent as a URL with ?form_data info appended to the end  Can be used only if data is all ASCII and not more than 100 characters  method="post"  Form data is sent in the body of the URL request  Cannot be bookmarked by most browsers  target="target"  Tells where to open the page sent as a result of the request  target= _blank means open in a new window  target= _top means use the same window 4
  • 5. The <input> tag  Most, but not all, form elements use the input tag, with a type="..." argument to tell which kind of element it is  type can be text, checkbox, radio, password, hidden, submit, reset, button, file, or image  Other common input tag arguments include:  name: the name of the element  value: the “value” of the element; used in different ways for different values of type  readonly: the value cannot be changed  disabled: the user can’t do anything with this element  Other arguments are defined for the input tag but have meaning only for certain values of type 5
  • 6. Text input 6 A text field: <input type="text" name="textfield" value="with an initial value"> A multi-line text field <textarea name="textarea" cols="24" rows="2">Hello</textarea> A password field: <input type="password" name="textfield3" value="secret"> • Note that two of these use the input tag, but one uses textarea
  • 7. Buttons  A submit button: <input type="submit" name="Submit" value="Submit">  A reset button: <input type="reset" name="Submit2" value="Reset">  A plain button: <input type="button" name="Submit3" value="Push Me">  submit: send data  reset: restore all form elements to their initial state  button: take some action as specified by JavaScript 7 • Note that the type is input, not “button”
  • 8. Checkboxes  A checkbox: <input type="checkbox" name="checkbox” value="checkbox" checked>  type: "checkbox"  name: used to reference this form element from JavaScript  value: value to be returned when element is checked  Note that there is no text associated with the checkbox—you have to supply text in the surrounding HTML 8
  • 9. Radio buttons Radio buttons:<br> <input type="radio" name="radiobutton" value="myValue1"> male<br> <input type="radio" name="radiobutton" value="myValue2" checked> female  If two or more radio buttons have the same name, the user can only select one of them at a time  This is how you make a radio button “group”  If you ask for the value of that name, you will get the value specified for the selected radio button  As with checkboxes, radio buttons do not contain any text 9
  • 10. Drop-down menu or list  A menu or list: <select name="select"> <option value="red">red</option> <option value="green">green</option> <option value="BLUE">blue</option> </select>  Additional arguments:  size: the number of items visible in the list (default is "1")  multiple: if set to "true", any number of items may be selected (default is "false") 10
  • 11. Hidden fields  <input type="hidden" name="hiddenField" value="nyah"> &lt;-- right there, don't you see it?  What good is this?  All input fields are sent back to the server, including hidden fields  This is a way to include information that the user doesn’t need to see (or that you don’t want her to see)  The value of a hidden field can be set programmatically (by JavaScript) before the form is submitted 11
  • 12. A complete example<html> <head> <title>Get Identity</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <p><b>Who are you?</b></p> <form method="post" action=""> <p>Name: <input type="text" name="textfield"> </p> <p>Gender: <input type="radio" name="gender" value="m">Male <input type="radio" name="gender" value="f">Female</p> </form> </body> </html> 12