SlideShare a Scribd company logo
1 of 32
By : SURBHI SAROHA
SYLLABUS
 Introduction to Client Side Scripting.
 Introduction to Java Scripts
 Javascript types
 Variables in JS
 Operators in JS
 Conditions Statements
 Java Script Loops
 JS Popup Boxes
 JS Events
 JS Arrays
 Working with Arrays
 JS Objects
 JS Functions
 Using Java Script in Real time
 Validation of Forms
 Related Examples.
Introduction to Client Side
Scripting.
 Scripts in ServiceNow fall into two categories:
 Client-side
 Server-side
 This module is about client-side scripting. Client-side scripts execute
within a user's browser and are used to manage forms and form fields.
Examples of things client-side scripts can do include:
 Place the cursor in a form field on form load
 Generate alerts, confirmations, and messages
 Populate a form field in response to another field's value
 Highlight a form field
 Validate form data
 Modify choice list options
 Hide/Show fields or sections
Client-Side Scripting: Javascript
 For a Web page, HTML supplies document content
and structure while CSS provides presentation styling.
In addition, client-side scripts can control browser
actions associated with a Web page.
 Scripts are programs written in a simple and easy-to-
use language to specify control of other programs.
 Client-side scripts are almost always written in the
Javascript language to control browsers actions.
Cont….
 Tasks performed with client-side scripts include:
 • Asking the browser to display information
 • Making the Web page different depending on the browser
and browser features
 • Monitoring user events and specifying reactions
 • Generating HTML code for parts of the page
 • Modifying a page in response to events
 • Checking correctness of user input
 • Replacing and updating parts of a page
 • Changing the style and position of displayed elements
dynamically
Introduction to Java Scripts
 Javascript is a widely used scripting language originally
developed by Netscape for both client-side and server-side
scripting.
 The language is becoming an international standard,
approved by the European standards body ECMA (ECMA-
262) in 1997 and later by the ISO in 1998.
 Client-side Javascript is used widely and supported well by
major browsers including NN, IE, AOL, MOZILLA, and
Opera.
 We shall present client-side Javascript for adding
dynamism and interactivity to Web pages and will refer to
it simply as Javascript.
Cont…
 The host environment also provides a means to
connect scripting code with events such as focus and
mouse actions, page and image loading, form input
and submission, error and abort.
 Scripting code can also perform computation as the
page is loading.
 Thus, the displayed page is the result of a combination
of HTML, CSS, and Javascript actions.
Cont….
 JavaScript was initially created to “make web pages
alive”.
 The programs in this language are called scripts. They
can be written right in a web page’s HTML and run
automatically as the page loads.
 Scripts are provided and executed as plain text. They
don’t need special preparation or compilation to run.
 In this aspect, JavaScript is very different from another
language called Java.
History of JavaScript:
 It was created in 1995 by Brendan Eich while he was
an engineer at Netscape.
 It was originally going to be named LiveScript but was
renamed. Unlike most programming languages, the
JavaScript language has no concept of input or output.
 It is designed to run as a scripting language in a host
environment, and it is up to the host environment to
provide mechanisms for communicating with the
outside world.
 The most common host environment is the browser.
Javascript types
 JavaScript variables can hold many data types:
numbers, strings and objects.
 var length = 16; // Number

var lastName = "Johnson"; // String

var x = {firstName:"John", lastName:"Doe"}; // Object
Cnt.
 JavaScript has dynamic types. This means that the same
variable can be used to hold different data types.
 var x; // Now x is undefined
x = 5; // Now x is a Number
x = "John"; // Now x is a String
 JavaScript Booleans
 Booleans can only have two values: true or false.
 var x = 5;
var y = 5;
var z = 6;
(x == y) // Returns true
(x == z) // Returns false
Variables in JS
 JavaScript variables are containers for storing data values.
 In this example, x, y, and z, are variables, declared with
the var keyword:
 var x = 5;
var y = 6;
var z = x + y;
 From the example above, you can expect:
 x stores the value 5
 y stores the value 6
 z stores the value 11
Operators in JS
 The assignment operator (=) assigns a value to a variable.
 var x = 10;
 The addition operator (+) adds numbers:
 var x = 5;
var y = 2;
var z = x + y;
 The multiplication operator (*) multiplies numbers.
 var x = 5;
var y = 2;
var z = x * y;
JavaScript Arithmetic Operators
 Arithmetic operators are used to perform arithmetic on
numbers:
 Operator Description
 + Addition
 - Subtraction
 * Multiplication
 ** Exponentiation
 / Division
 % Modulus (Division Remainder)
 ++ Increment
 -- Decrement
JavaScript String Operators
 The + operator can also be used to add (concatenate)
strings.
 Example
 var txt1 = "John";
var txt2 = "Doe";
var txt3 = txt1 + " " + txt2;
 The result of txt3 will be:
 John Doe
JavaScript Comparison Operators
 Operator Description
 == equal to
 === equal value and equal type
 != not equal
 !== not equal value or not equal type
 > greater than
 < less than
 >= greater than or equal to
 <= less than or equal to
 ? ternary operator
JavaScript Logical Operators
 Operator Description
 && logical and
 || logical or
 ! logical not
 JavaScript Type Operators
 Operator Description
 Typeof Returns the type of a variable
 Instanceof Returns true if an object is an instance
of an object type
JavaScript Bitwise Operators
 Bit operators work on 32 bits numbers.
 Any numeric operand in the operation is converted
into a 32 bit number. The result is converted back to a
JavaScript number.
 &AND
 |OR
 ~NOT
 ^XOR
 <<Zero fill left shift
 >> Zero fill right shift
Conditions Statements
 Very often when you write code, you want to perform
different actions for different decisions.
 You can use conditional statements in your code to do this.
 In JavaScript we have the following conditional statements:
 Use if to specify a block of code to be executed, if a
specified condition is true
 Use else to specify a block of code to be executed, if the
same condition is false
 Use else if to specify a new condition to test, if the first
condition is false
 Use switch to specify many alternative blocks of code to be
executed
Java Script Loops
 Loops are handy, if you want to run the same code over and
over again, each time with a different value.
 JavaScript supports different kinds of loops:
 for - loops through a block of code a number of times
 for/in - loops through the properties of an object
 for/of - loops through the values of an iterable object
 while - loops through a block of code while a specified
condition is true
 do/while - also loops through a block of code while a
specified condition is true

JS Popup Boxes
 avaScript has three kind of popup boxes: Alert box, Confirm box,
and Prompt box.
 Alert Box
 An alert box is often used if you want to make sure information
comes through to the user.
 When an alert box pops up, the user will have to click "OK" to
proceed.
 Syntax
 window.alert("sometext");
 The window.alert() method can be written without the window
prefix.
 Example
 alert("I am an alert box!");
Confirm Box
 A confirm box is often used if you want the user to verify or accept something.
 When a confirm box pops up, the user will have to click either "OK" or "Cancel"
to proceed.
 If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box
returns false.
 Syntax
 window.confirm("sometext");
 The window.confirm() method can be written without the window prefix.
 Example
 if (confirm("Press a button!")) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
}
Prompt Box
 A prompt box is often used if you want the user to input a value before entering
a page.
 When a prompt box pops up, the user will have to click either "OK" or "Cancel"
to proceed after entering an input value.
 If the user clicks "OK" the box returns the input value. If the user clicks
"Cancel" the box returns null.
 Syntax
 window.prompt("sometext","defaultText");
 The window.prompt() method can be written without the window prefix.
 Example
 var person = prompt("Please enter your name", "Harry Potter");
if (person == null || person == "") {
txt = "User cancelled the prompt.";
} else {
txt = "Hello " + person + "! How are you today?";
}
JS Events
 An HTML event can be something the browser does, or
something a user does.
 Here are some examples of HTML events:
 An HTML web page has finished loading.
 An HTML input field was changed.
 An HTML button was clicked.
 Often, when events happen, you may want to do
something.
 JavaScript lets you execute code when events are detected.
 HTML allows event handler attributes, with JavaScript
code, to be added to HTML elements.
Cont…
 With single quotes:
 <element event='some JavaScript'>
 With double quotes:
 <element event="some JavaScript">
JS Arrays
 JavaScript arrays are used to store multiple values in a
single variable.
 Ex: var cars = ["Saab", "Volvo", "BMW"];
 An array is a special variable, which can hold more
than one value at a time.
 If you have a list of items (a list of car names, for
example), storing the cars in single variables could
look like this:
 var car1 = "Saab";
var car2 = "Volvo";
var car3 = "BMW";
JS Functions
 A JavaScript function is a block of code designed to
perform a particular task.
 A JavaScript function is executed when "something"
invokes it (calls it).
 Ex:
 function myFunction(p1, p2) {
return p1 * p2; // The function returns the product
of p1 and p2
}
JavaScript Function Syntax
 A JavaScript function is defined with the function keyword, followed by
a name, followed by parentheses ().
 Function names can contain letters, digits, underscores, and dollar signs (same
rules as variables).
 The parentheses may include parameter names separated by commas:
(parameter1, parameter2, ...)
 The code to be executed, by the function, is placed inside curly brackets: {}
 function name(parameter1, parameter2, parameter3) {
// code to be executed
}
 Function parameters are listed inside the parentheses () in the function
definition.
 Function arguments are the values received by the function when it is
invoked.
 Inside the function, the arguments (the parameters) behave as local variables.
 A Function is much the same as a Procedure or a Subroutine, in other
programming languages.
Validation of Forms
 HTML form validation can be done by JavaScript.
 If a form field (fname) is empty, this function alerts a
message, and returns false, to prevent the form from being
submitted:
 JavaScript Example
 function validateForm() {
var x = document.forms["myForm"]["fname"].value;
if (x == "") {
alert("Name must be filled out");
return false;
}
}
Example
 <!DOCTYPE html>
 <html>
 <body>
 <p>Enter a number and click OK:</p>
 <input id="id1" type="number" min="100" max="300" required>
 <button onclick="myFunction()">OK</button>
 <p>If the number is less than 100 or greater than 300, an error message will be
displayed.</p>
 <p id="demo"></p>
 <script>
 function myFunction() {
 var inpObj = document.getElementById("id1");
Cont….
 if (!inpObj.checkValidity()) {
 document.getElementById("demo").innerHTML =
inpObj.validationMessage;
 } else {
 document.getElementById("demo").innerHTML =
"Input OK";
 }
 }
 </script>
 </body>
 </html>
Thank you 

More Related Content

What's hot (20)

Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Html
HtmlHtml
Html
 
Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1
 
Responsive web designing ppt(1)
Responsive web designing ppt(1)Responsive web designing ppt(1)
Responsive web designing ppt(1)
 
Web Devlopment ppt.pptx
Web Devlopment ppt.pptxWeb Devlopment ppt.pptx
Web Devlopment ppt.pptx
 
Software quality assurance
Software quality assuranceSoftware quality assurance
Software quality assurance
 
Php
PhpPhp
Php
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
HTML: Chapter 01
HTML: Chapter 01HTML: Chapter 01
HTML: Chapter 01
 
PHP - Introduction to PHP AJAX
PHP -  Introduction to PHP AJAXPHP -  Introduction to PHP AJAX
PHP - Introduction to PHP AJAX
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
 
Javascript essentials
Javascript essentialsJavascript essentials
Javascript essentials
 
Web application framework
Web application frameworkWeb application framework
Web application framework
 
Responsive Web Design with HTML5 and CSS3
Responsive Web Design with HTML5 and CSS3Responsive Web Design with HTML5 and CSS3
Responsive Web Design with HTML5 and CSS3
 
Dynamic HTML (DHTML)
Dynamic HTML (DHTML)Dynamic HTML (DHTML)
Dynamic HTML (DHTML)
 
Responsive web design
Responsive web designResponsive web design
Responsive web design
 
Javascript
JavascriptJavascript
Javascript
 
Css3
Css3Css3
Css3
 
Introduction to HTML5 Canvas
Introduction to HTML5 CanvasIntroduction to HTML5 Canvas
Introduction to HTML5 Canvas
 
Introduction to VB.net
Introduction to VB.netIntroduction to VB.net
Introduction to VB.net
 

Similar to Web designing unit 4

Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoftch samaram
 
Introduction to Javascript programming
Introduction to Javascript programmingIntroduction to Javascript programming
Introduction to Javascript programmingFulvio Corno
 
Basic Java script handouts for students
Basic Java script handouts for students Basic Java script handouts for students
Basic Java script handouts for students shafiq sangi
 
Java script.pptx v
Java script.pptx                                     vJava script.pptx                                     v
Java script.pptx v22x026
 
IT2255 Web Essentials - Unit III Client-Side Processing and Scripting
IT2255 Web Essentials - Unit III Client-Side Processing and ScriptingIT2255 Web Essentials - Unit III Client-Side Processing and Scripting
IT2255 Web Essentials - Unit III Client-Side Processing and Scriptingpkaviya
 
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPTHSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPTAAFREEN SHAIKH
 
JavaScript Lecture notes.pptx
JavaScript Lecture notes.pptxJavaScript Lecture notes.pptx
JavaScript Lecture notes.pptxNishaRohit6
 
Java script basics
Java script basicsJava script basics
Java script basicsJohn Smith
 
JavaScript with Syntax & Implementation
JavaScript with Syntax & ImplementationJavaScript with Syntax & Implementation
JavaScript with Syntax & ImplementationSoumen Santra
 

Similar to Web designing unit 4 (20)

Web programming
Web programmingWeb programming
Web programming
 
Unit 2.4
Unit 2.4Unit 2.4
Unit 2.4
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
 
Java scipt
Java sciptJava scipt
Java scipt
 
Unit 2.4
Unit 2.4Unit 2.4
Unit 2.4
 
Javascript
JavascriptJavascript
Javascript
 
wp-UNIT_III.pptx
wp-UNIT_III.pptxwp-UNIT_III.pptx
wp-UNIT_III.pptx
 
Introduction to Javascript programming
Introduction to Javascript programmingIntroduction to Javascript programming
Introduction to Javascript programming
 
Basic Java script handouts for students
Basic Java script handouts for students Basic Java script handouts for students
Basic Java script handouts for students
 
Java script
Java scriptJava script
Java script
 
Java script.pptx v
Java script.pptx                                     vJava script.pptx                                     v
Java script.pptx v
 
JS basics
JS basicsJS basics
JS basics
 
IT2255 Web Essentials - Unit III Client-Side Processing and Scripting
IT2255 Web Essentials - Unit III Client-Side Processing and ScriptingIT2255 Web Essentials - Unit III Client-Side Processing and Scripting
IT2255 Web Essentials - Unit III Client-Side Processing and Scripting
 
Javascript
JavascriptJavascript
Javascript
 
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPTHSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
 
Javascript
JavascriptJavascript
Javascript
 
JavaScript Lecture notes.pptx
JavaScript Lecture notes.pptxJavaScript Lecture notes.pptx
JavaScript Lecture notes.pptx
 
Java script basics
Java script basicsJava script basics
Java script basics
 
JavaScript with Syntax & Implementation
JavaScript with Syntax & ImplementationJavaScript with Syntax & Implementation
JavaScript with Syntax & Implementation
 
Javascript
JavascriptJavascript
Javascript
 

More from SURBHI SAROHA

Cloud Computing (Infrastructure as a Service)UNIT 2
Cloud Computing (Infrastructure as a Service)UNIT 2Cloud Computing (Infrastructure as a Service)UNIT 2
Cloud Computing (Infrastructure as a Service)UNIT 2SURBHI SAROHA
 
Management Information System(Unit 2).pptx
Management Information System(Unit 2).pptxManagement Information System(Unit 2).pptx
Management Information System(Unit 2).pptxSURBHI SAROHA
 
Searching in Data Structure(Linear search and Binary search)
Searching in Data Structure(Linear search and Binary search)Searching in Data Structure(Linear search and Binary search)
Searching in Data Structure(Linear search and Binary search)SURBHI SAROHA
 
Management Information System(UNIT 1).pptx
Management Information System(UNIT 1).pptxManagement Information System(UNIT 1).pptx
Management Information System(UNIT 1).pptxSURBHI SAROHA
 
Introduction to Cloud Computing(UNIT 1).pptx
Introduction to Cloud Computing(UNIT 1).pptxIntroduction to Cloud Computing(UNIT 1).pptx
Introduction to Cloud Computing(UNIT 1).pptxSURBHI SAROHA
 
Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)SURBHI SAROHA
 
Database Management System(UNIT 1)
Database Management System(UNIT 1)Database Management System(UNIT 1)
Database Management System(UNIT 1)SURBHI SAROHA
 
Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1SURBHI SAROHA
 
Database Management System(UNIT 1)
Database Management System(UNIT 1)Database Management System(UNIT 1)
Database Management System(UNIT 1)SURBHI SAROHA
 

More from SURBHI SAROHA (20)

Cloud Computing (Infrastructure as a Service)UNIT 2
Cloud Computing (Infrastructure as a Service)UNIT 2Cloud Computing (Infrastructure as a Service)UNIT 2
Cloud Computing (Infrastructure as a Service)UNIT 2
 
Management Information System(Unit 2).pptx
Management Information System(Unit 2).pptxManagement Information System(Unit 2).pptx
Management Information System(Unit 2).pptx
 
Searching in Data Structure(Linear search and Binary search)
Searching in Data Structure(Linear search and Binary search)Searching in Data Structure(Linear search and Binary search)
Searching in Data Structure(Linear search and Binary search)
 
Management Information System(UNIT 1).pptx
Management Information System(UNIT 1).pptxManagement Information System(UNIT 1).pptx
Management Information System(UNIT 1).pptx
 
Introduction to Cloud Computing(UNIT 1).pptx
Introduction to Cloud Computing(UNIT 1).pptxIntroduction to Cloud Computing(UNIT 1).pptx
Introduction to Cloud Computing(UNIT 1).pptx
 
JAVA (UNIT 5)
JAVA (UNIT 5)JAVA (UNIT 5)
JAVA (UNIT 5)
 
DBMS (UNIT 5)
DBMS (UNIT 5)DBMS (UNIT 5)
DBMS (UNIT 5)
 
DBMS UNIT 4
DBMS UNIT 4DBMS UNIT 4
DBMS UNIT 4
 
JAVA(UNIT 4)
JAVA(UNIT 4)JAVA(UNIT 4)
JAVA(UNIT 4)
 
OOPs & C++(UNIT 5)
OOPs & C++(UNIT 5)OOPs & C++(UNIT 5)
OOPs & C++(UNIT 5)
 
OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)
 
DBMS UNIT 3
DBMS UNIT 3DBMS UNIT 3
DBMS UNIT 3
 
JAVA (UNIT 3)
JAVA (UNIT 3)JAVA (UNIT 3)
JAVA (UNIT 3)
 
Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)
 
DBMS (UNIT 2)
DBMS (UNIT 2)DBMS (UNIT 2)
DBMS (UNIT 2)
 
JAVA UNIT 2
JAVA UNIT 2JAVA UNIT 2
JAVA UNIT 2
 
Database Management System(UNIT 1)
Database Management System(UNIT 1)Database Management System(UNIT 1)
Database Management System(UNIT 1)
 
Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1
 
Database Management System(UNIT 1)
Database Management System(UNIT 1)Database Management System(UNIT 1)
Database Management System(UNIT 1)
 
OOPs & C++ UNIT 3
OOPs & C++ UNIT 3OOPs & C++ UNIT 3
OOPs & C++ UNIT 3
 

Recently uploaded

Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 

Recently uploaded (20)

Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 

Web designing unit 4

  • 1. By : SURBHI SAROHA
  • 2. SYLLABUS  Introduction to Client Side Scripting.  Introduction to Java Scripts  Javascript types  Variables in JS  Operators in JS  Conditions Statements  Java Script Loops  JS Popup Boxes  JS Events  JS Arrays  Working with Arrays  JS Objects  JS Functions  Using Java Script in Real time  Validation of Forms  Related Examples.
  • 3. Introduction to Client Side Scripting.  Scripts in ServiceNow fall into two categories:  Client-side  Server-side  This module is about client-side scripting. Client-side scripts execute within a user's browser and are used to manage forms and form fields. Examples of things client-side scripts can do include:  Place the cursor in a form field on form load  Generate alerts, confirmations, and messages  Populate a form field in response to another field's value  Highlight a form field  Validate form data  Modify choice list options  Hide/Show fields or sections
  • 4. Client-Side Scripting: Javascript  For a Web page, HTML supplies document content and structure while CSS provides presentation styling. In addition, client-side scripts can control browser actions associated with a Web page.  Scripts are programs written in a simple and easy-to- use language to specify control of other programs.  Client-side scripts are almost always written in the Javascript language to control browsers actions.
  • 5. Cont….  Tasks performed with client-side scripts include:  • Asking the browser to display information  • Making the Web page different depending on the browser and browser features  • Monitoring user events and specifying reactions  • Generating HTML code for parts of the page  • Modifying a page in response to events  • Checking correctness of user input  • Replacing and updating parts of a page  • Changing the style and position of displayed elements dynamically
  • 6. Introduction to Java Scripts  Javascript is a widely used scripting language originally developed by Netscape for both client-side and server-side scripting.  The language is becoming an international standard, approved by the European standards body ECMA (ECMA- 262) in 1997 and later by the ISO in 1998.  Client-side Javascript is used widely and supported well by major browsers including NN, IE, AOL, MOZILLA, and Opera.  We shall present client-side Javascript for adding dynamism and interactivity to Web pages and will refer to it simply as Javascript.
  • 7. Cont…  The host environment also provides a means to connect scripting code with events such as focus and mouse actions, page and image loading, form input and submission, error and abort.  Scripting code can also perform computation as the page is loading.  Thus, the displayed page is the result of a combination of HTML, CSS, and Javascript actions.
  • 8. Cont….  JavaScript was initially created to “make web pages alive”.  The programs in this language are called scripts. They can be written right in a web page’s HTML and run automatically as the page loads.  Scripts are provided and executed as plain text. They don’t need special preparation or compilation to run.  In this aspect, JavaScript is very different from another language called Java.
  • 9. History of JavaScript:  It was created in 1995 by Brendan Eich while he was an engineer at Netscape.  It was originally going to be named LiveScript but was renamed. Unlike most programming languages, the JavaScript language has no concept of input or output.  It is designed to run as a scripting language in a host environment, and it is up to the host environment to provide mechanisms for communicating with the outside world.  The most common host environment is the browser.
  • 10. Javascript types  JavaScript variables can hold many data types: numbers, strings and objects.  var length = 16; // Number  var lastName = "Johnson"; // String  var x = {firstName:"John", lastName:"Doe"}; // Object
  • 11. Cnt.  JavaScript has dynamic types. This means that the same variable can be used to hold different data types.  var x; // Now x is undefined x = 5; // Now x is a Number x = "John"; // Now x is a String  JavaScript Booleans  Booleans can only have two values: true or false.  var x = 5; var y = 5; var z = 6; (x == y) // Returns true (x == z) // Returns false
  • 12. Variables in JS  JavaScript variables are containers for storing data values.  In this example, x, y, and z, are variables, declared with the var keyword:  var x = 5; var y = 6; var z = x + y;  From the example above, you can expect:  x stores the value 5  y stores the value 6  z stores the value 11
  • 13. Operators in JS  The assignment operator (=) assigns a value to a variable.  var x = 10;  The addition operator (+) adds numbers:  var x = 5; var y = 2; var z = x + y;  The multiplication operator (*) multiplies numbers.  var x = 5; var y = 2; var z = x * y;
  • 14. JavaScript Arithmetic Operators  Arithmetic operators are used to perform arithmetic on numbers:  Operator Description  + Addition  - Subtraction  * Multiplication  ** Exponentiation  / Division  % Modulus (Division Remainder)  ++ Increment  -- Decrement
  • 15. JavaScript String Operators  The + operator can also be used to add (concatenate) strings.  Example  var txt1 = "John"; var txt2 = "Doe"; var txt3 = txt1 + " " + txt2;  The result of txt3 will be:  John Doe
  • 16. JavaScript Comparison Operators  Operator Description  == equal to  === equal value and equal type  != not equal  !== not equal value or not equal type  > greater than  < less than  >= greater than or equal to  <= less than or equal to  ? ternary operator
  • 17. JavaScript Logical Operators  Operator Description  && logical and  || logical or  ! logical not  JavaScript Type Operators  Operator Description  Typeof Returns the type of a variable  Instanceof Returns true if an object is an instance of an object type
  • 18. JavaScript Bitwise Operators  Bit operators work on 32 bits numbers.  Any numeric operand in the operation is converted into a 32 bit number. The result is converted back to a JavaScript number.  &AND  |OR  ~NOT  ^XOR  <<Zero fill left shift  >> Zero fill right shift
  • 19. Conditions Statements  Very often when you write code, you want to perform different actions for different decisions.  You can use conditional statements in your code to do this.  In JavaScript we have the following conditional statements:  Use if to specify a block of code to be executed, if a specified condition is true  Use else to specify a block of code to be executed, if the same condition is false  Use else if to specify a new condition to test, if the first condition is false  Use switch to specify many alternative blocks of code to be executed
  • 20. Java Script Loops  Loops are handy, if you want to run the same code over and over again, each time with a different value.  JavaScript supports different kinds of loops:  for - loops through a block of code a number of times  for/in - loops through the properties of an object  for/of - loops through the values of an iterable object  while - loops through a block of code while a specified condition is true  do/while - also loops through a block of code while a specified condition is true 
  • 21. JS Popup Boxes  avaScript has three kind of popup boxes: Alert box, Confirm box, and Prompt box.  Alert Box  An alert box is often used if you want to make sure information comes through to the user.  When an alert box pops up, the user will have to click "OK" to proceed.  Syntax  window.alert("sometext");  The window.alert() method can be written without the window prefix.  Example  alert("I am an alert box!");
  • 22. Confirm Box  A confirm box is often used if you want the user to verify or accept something.  When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed.  If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.  Syntax  window.confirm("sometext");  The window.confirm() method can be written without the window prefix.  Example  if (confirm("Press a button!")) { txt = "You pressed OK!"; } else { txt = "You pressed Cancel!"; }
  • 23. Prompt Box  A prompt box is often used if you want the user to input a value before entering a page.  When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value.  If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null.  Syntax  window.prompt("sometext","defaultText");  The window.prompt() method can be written without the window prefix.  Example  var person = prompt("Please enter your name", "Harry Potter"); if (person == null || person == "") { txt = "User cancelled the prompt."; } else { txt = "Hello " + person + "! How are you today?"; }
  • 24. JS Events  An HTML event can be something the browser does, or something a user does.  Here are some examples of HTML events:  An HTML web page has finished loading.  An HTML input field was changed.  An HTML button was clicked.  Often, when events happen, you may want to do something.  JavaScript lets you execute code when events are detected.  HTML allows event handler attributes, with JavaScript code, to be added to HTML elements.
  • 25. Cont…  With single quotes:  <element event='some JavaScript'>  With double quotes:  <element event="some JavaScript">
  • 26. JS Arrays  JavaScript arrays are used to store multiple values in a single variable.  Ex: var cars = ["Saab", "Volvo", "BMW"];  An array is a special variable, which can hold more than one value at a time.  If you have a list of items (a list of car names, for example), storing the cars in single variables could look like this:  var car1 = "Saab"; var car2 = "Volvo"; var car3 = "BMW";
  • 27. JS Functions  A JavaScript function is a block of code designed to perform a particular task.  A JavaScript function is executed when "something" invokes it (calls it).  Ex:  function myFunction(p1, p2) { return p1 * p2; // The function returns the product of p1 and p2 }
  • 28. JavaScript Function Syntax  A JavaScript function is defined with the function keyword, followed by a name, followed by parentheses ().  Function names can contain letters, digits, underscores, and dollar signs (same rules as variables).  The parentheses may include parameter names separated by commas: (parameter1, parameter2, ...)  The code to be executed, by the function, is placed inside curly brackets: {}  function name(parameter1, parameter2, parameter3) { // code to be executed }  Function parameters are listed inside the parentheses () in the function definition.  Function arguments are the values received by the function when it is invoked.  Inside the function, the arguments (the parameters) behave as local variables.  A Function is much the same as a Procedure or a Subroutine, in other programming languages.
  • 29. Validation of Forms  HTML form validation can be done by JavaScript.  If a form field (fname) is empty, this function alerts a message, and returns false, to prevent the form from being submitted:  JavaScript Example  function validateForm() { var x = document.forms["myForm"]["fname"].value; if (x == "") { alert("Name must be filled out"); return false; } }
  • 30. Example  <!DOCTYPE html>  <html>  <body>  <p>Enter a number and click OK:</p>  <input id="id1" type="number" min="100" max="300" required>  <button onclick="myFunction()">OK</button>  <p>If the number is less than 100 or greater than 300, an error message will be displayed.</p>  <p id="demo"></p>  <script>  function myFunction() {  var inpObj = document.getElementById("id1");
  • 31. Cont….  if (!inpObj.checkValidity()) {  document.getElementById("demo").innerHTML = inpObj.validationMessage;  } else {  document.getElementById("demo").innerHTML = "Input OK";  }  }  </script>  </body>  </html>