SlideShare a Scribd company logo
OCR H046/H466
SLR12 Web technologies | JavaScript
Inputting data
• Form controls can be inserted into a web page using a <form> tag.
• The action attribute tells the browser it needs to send any submitted form data to a page on the server called action_page.php.
• This PHP file handles the server’s processing of the form data. However, PHP is beyond the scope of the specification.
• You will not be expected to memorise this – exam questions will focus on what is done with the input once it is received.
My first form
<form id="form1" action="/action_page.php">
OCR H046/H466
SLR12 Web technologies | JavaScript
Inputting data
• Simple text boxes and buttons are defined with the <input> tag. The type attribute determines the type of input – for example:
o Text box: type="text"
o Submit button: type="submit"
• Notice how the inputs are given an id (e.g., id=“forename“) – this is essentially a variable, so you can refer to it using JavaScript.
• You only need to know about creating a text input and submit button for the exams, although other input options can be achieved in a
similar way using alternative tags.
My first form
<input type="text" id=“forename" name=" forename ">
OCR H046/H466
SLR12 Web technologies | JavaScript
Outputting data
• Here, we have used a button outside the form which, when clicked, will trigger the JavaScript code below inside the <script> tags.
• The onclick="myFunction()" part is telling the browser the name of the JavaScript function it needs to run when the button is clicked.
My first form
<button onclick="myFunction()">Try Javascript</button>
OCR H046/H466
SLR12 Web technologies | JavaScript
Outputting data
• The next line is an output identifier used to capture the output from the JavaScript code.
My first form
<p id="output_here"></p>
OCR H046/H466
SLR12 Web technologies | JavaScript
Outputting data
• The actual JavaScript code is enclosed in a set of HTML <script> tags.
• Notice how JavaScript code is similar to code from the language you have been learning but with slightly different syntax.
• You will need to be familiar with the JavaScript equivalents of the structures mentioned in the specification.
My first form
OCR H046/H466
SLR12 Web technologies | JavaScript
Outputting data
• Lets look at JavaScript code in more detail – you will already be familiar with many of the programming concepts:
o Command lines are terminated with a semicolon.
o Curly brackets are used to define sections of code.
o Functions are defined.
o Variables are defined.
o For loops work.
My first form
function myFunction() {
var x = document.getElementById("form1");
var text = "";
var i;
for (i = 0; i < x.length ;i++) {
data = x.elements[i].value;
if (data!="Submit") {
text += "Your name was entered as " + data + ".";
}
}
document.getElementById("output_here").innerHTML = text;
}
OCR H046/H466
SLR12 Web technologies | JavaScript
Outputting data
• Lets look at JavaScript code in more detail – you will already be familiar with many of the programming concepts:
o An array of inputs can be referred to.
o Variables are assigned values.
o An if condition can be used for selection.
o The output is returned to the page.
My first form
function myFunction() {
var x = document.getElementById("form1");
var text = "";
var i;
for (i = 0; i < x.length ;i++) {
data = x.elements[i].value;
if (data!="Submit") {
text += "Your name was entered as " + data + ".";
}
}
document.getElementById("output_here").innerHTML = text;
}
OCR H046/H466
SLR12 Web technologies | JavaScript
Outputting data
• The above code changes the contents of an existing HTML element called output_here.
• You can write directly to the document using: document.write("Hello World");
• You can also use pop-up alert boxes: alert("Hello World");
My first form

More Related Content

Similar to Tutorial on Javascript Form

ASP DOT NET
ASP DOT NETASP DOT NET
ASP DOT NET
Pratik Tambekar
 
Final Java-script.pptx
Final Java-script.pptxFinal Java-script.pptx
Final Java-script.pptx
AlkanthiSomesh
 
Java script
Java scriptJava script
Java script
Jay Patel
 
Html5ppt
Html5pptHtml5ppt
Html5pptrecroup
 
Lecture2_IntroductionToPHP_Spring2023.pdf
Lecture2_IntroductionToPHP_Spring2023.pdfLecture2_IntroductionToPHP_Spring2023.pdf
Lecture2_IntroductionToPHP_Spring2023.pdf
ShaimaaMohamedGalal
 
Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2
Gheyath M. Othman
 
Javascript
JavascriptJavascript
Javascript
Sun Technlogies
 
Pascarello_Investigating JavaScript and Ajax Security
Pascarello_Investigating JavaScript and Ajax SecurityPascarello_Investigating JavaScript and Ajax Security
Pascarello_Investigating JavaScript and Ajax Security
amiable_indian
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)
Ajay Khatri
 
Access tips access and sql part 4 building select queries on-the-fly
Access tips  access and sql part 4  building select queries on-the-flyAccess tips  access and sql part 4  building select queries on-the-fly
Access tips access and sql part 4 building select queries on-the-fly
quest2900
 
Working with data.pptx
Working with data.pptxWorking with data.pptx
Working with data.pptx
SherinRappai
 
Javascript
JavascriptJavascript
Javascript
Prashant Kumar
 
PHP - Introduction to PHP Date and Time Functions
PHP -  Introduction to  PHP Date and Time FunctionsPHP -  Introduction to  PHP Date and Time Functions
PHP - Introduction to PHP Date and Time Functions
Vibrant Technologies & Computers
 
Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)
Thinkful
 
Advisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptAdvisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptdominion
 
PHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginnersPHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginners
Mohammed Mushtaq Ahmed
 
Java script
Java scriptJava script
Java script
Sadeek Mohammed
 
JavaScriptL18 [Autosaved].pptx
JavaScriptL18 [Autosaved].pptxJavaScriptL18 [Autosaved].pptx
JavaScriptL18 [Autosaved].pptx
VivekBaghel30
 
Html basics 11 form validation
Html basics 11 form validationHtml basics 11 form validation
Html basics 11 form validationH K
 
Lesson 1
Lesson 1Lesson 1
Lesson 1
vmmanikandan
 

Similar to Tutorial on Javascript Form (20)

ASP DOT NET
ASP DOT NETASP DOT NET
ASP DOT NET
 
Final Java-script.pptx
Final Java-script.pptxFinal Java-script.pptx
Final Java-script.pptx
 
Java script
Java scriptJava script
Java script
 
Html5ppt
Html5pptHtml5ppt
Html5ppt
 
Lecture2_IntroductionToPHP_Spring2023.pdf
Lecture2_IntroductionToPHP_Spring2023.pdfLecture2_IntroductionToPHP_Spring2023.pdf
Lecture2_IntroductionToPHP_Spring2023.pdf
 
Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2
 
Javascript
JavascriptJavascript
Javascript
 
Pascarello_Investigating JavaScript and Ajax Security
Pascarello_Investigating JavaScript and Ajax SecurityPascarello_Investigating JavaScript and Ajax Security
Pascarello_Investigating JavaScript and Ajax Security
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)
 
Access tips access and sql part 4 building select queries on-the-fly
Access tips  access and sql part 4  building select queries on-the-flyAccess tips  access and sql part 4  building select queries on-the-fly
Access tips access and sql part 4 building select queries on-the-fly
 
Working with data.pptx
Working with data.pptxWorking with data.pptx
Working with data.pptx
 
Javascript
JavascriptJavascript
Javascript
 
PHP - Introduction to PHP Date and Time Functions
PHP -  Introduction to  PHP Date and Time FunctionsPHP -  Introduction to  PHP Date and Time Functions
PHP - Introduction to PHP Date and Time Functions
 
Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)
 
Advisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptAdvisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScript
 
PHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginnersPHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginners
 
Java script
Java scriptJava script
Java script
 
JavaScriptL18 [Autosaved].pptx
JavaScriptL18 [Autosaved].pptxJavaScriptL18 [Autosaved].pptx
JavaScriptL18 [Autosaved].pptx
 
Html basics 11 form validation
Html basics 11 form validationHtml basics 11 form validation
Html basics 11 form validation
 
Lesson 1
Lesson 1Lesson 1
Lesson 1
 

Recently uploaded

Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
ViralQR
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 

Recently uploaded (20)

Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 

Tutorial on Javascript Form

  • 1. OCR H046/H466 SLR12 Web technologies | JavaScript Inputting data • Form controls can be inserted into a web page using a <form> tag. • The action attribute tells the browser it needs to send any submitted form data to a page on the server called action_page.php. • This PHP file handles the server’s processing of the form data. However, PHP is beyond the scope of the specification. • You will not be expected to memorise this – exam questions will focus on what is done with the input once it is received. My first form <form id="form1" action="/action_page.php">
  • 2. OCR H046/H466 SLR12 Web technologies | JavaScript Inputting data • Simple text boxes and buttons are defined with the <input> tag. The type attribute determines the type of input – for example: o Text box: type="text" o Submit button: type="submit" • Notice how the inputs are given an id (e.g., id=“forename“) – this is essentially a variable, so you can refer to it using JavaScript. • You only need to know about creating a text input and submit button for the exams, although other input options can be achieved in a similar way using alternative tags. My first form <input type="text" id=“forename" name=" forename ">
  • 3. OCR H046/H466 SLR12 Web technologies | JavaScript Outputting data • Here, we have used a button outside the form which, when clicked, will trigger the JavaScript code below inside the <script> tags. • The onclick="myFunction()" part is telling the browser the name of the JavaScript function it needs to run when the button is clicked. My first form <button onclick="myFunction()">Try Javascript</button>
  • 4. OCR H046/H466 SLR12 Web technologies | JavaScript Outputting data • The next line is an output identifier used to capture the output from the JavaScript code. My first form <p id="output_here"></p>
  • 5. OCR H046/H466 SLR12 Web technologies | JavaScript Outputting data • The actual JavaScript code is enclosed in a set of HTML <script> tags. • Notice how JavaScript code is similar to code from the language you have been learning but with slightly different syntax. • You will need to be familiar with the JavaScript equivalents of the structures mentioned in the specification. My first form
  • 6. OCR H046/H466 SLR12 Web technologies | JavaScript Outputting data • Lets look at JavaScript code in more detail – you will already be familiar with many of the programming concepts: o Command lines are terminated with a semicolon. o Curly brackets are used to define sections of code. o Functions are defined. o Variables are defined. o For loops work. My first form function myFunction() { var x = document.getElementById("form1"); var text = ""; var i; for (i = 0; i < x.length ;i++) { data = x.elements[i].value; if (data!="Submit") { text += "Your name was entered as " + data + "."; } } document.getElementById("output_here").innerHTML = text; }
  • 7. OCR H046/H466 SLR12 Web technologies | JavaScript Outputting data • Lets look at JavaScript code in more detail – you will already be familiar with many of the programming concepts: o An array of inputs can be referred to. o Variables are assigned values. o An if condition can be used for selection. o The output is returned to the page. My first form function myFunction() { var x = document.getElementById("form1"); var text = ""; var i; for (i = 0; i < x.length ;i++) { data = x.elements[i].value; if (data!="Submit") { text += "Your name was entered as " + data + "."; } } document.getElementById("output_here").innerHTML = text; }
  • 8. OCR H046/H466 SLR12 Web technologies | JavaScript Outputting data • The above code changes the contents of an existing HTML element called output_here. • You can write directly to the document using: document.write("Hello World"); • You can also use pop-up alert boxes: alert("Hello World"); My first form