SlideShare uma empresa Scribd logo
1 de 57
WHAT WE RE GOING TO DO
 Pretest & Review of Javascript Basics
 Digging in –
 Event Handling
 HTML Forms Validation
 JS Libraries
 Testing/Debugging
WHAT IS JAVASCRIPT
Object based (not object oriented) programming
language
 very limited object creation
 a set of pre-defined objects associated with
 HTML document structure
 many HTML tags constitute JS Objects
 Browser functionality
 provides a limited API to Browser functionality
JAVASCRIPT…JAVA ?
There is no relationship other than the fact that Java and JavaScript
resemble each other (and C++) syntactically
JavaScript is pretty much the de-facto standard for client-side scripting
WHAT CAN IT BE USED FOR
Some pretty amazing things….
 Text animation
 graphic animation
 simple browser based application
 HTML forms submission
 client-side forms data validation (relieving the server of this task)
 web site navigation
PUTTING JAVASCRIPT INTO YOUR HTML
in an external file
 collect commonly used functions together into external function
libraries on the server
 added benefit of privacy from all but the most curious users
in-line with your HTML
as an expression for an HTML tag attribute
within some HTML tags as Event Handlers
<SCRIPT>
<SCRIPT LANGUAGE= JavaScript >
<!-- start hiding code from old browsers>
Your
Javascript
Code
Goes
Here
// Stop Hiding code -->
</SCRIPT>
PROGRAMMING FUNDAMENTALS
Value Types
 String Sample
 Number 2.52 , 5 , .5
 Boolean true, false
 Null null
 Object - all properties and methods belonging to the object or array
 Function - a function definition
VARIABLES
Naming
 start with alpha followed by alphameric (and _)
Creating
 use the var keyword
 var myName
 definition and initialization can be combined
 var myName = Dick
ARRAYS
One dimensional arrays
 var myarray = new Array( ) //empty array
 var myarray1 = new Array(10) // 10 elements
 var myarray2 = new Array(2,4,6) // 3 elements initialized to 2, 4,
and 6 respectively
0 based - myarray[0] is first element
USER DEFINED OBJECTS
Implemented as associative arrays
 var point = new Object() // empty object
 point.x = 5 ; point.y = 3; // no longer empty
 var newpoint = {x:4 , y:5} // object literal form
 var anotherpoint = new Object( )
 anotherpoint = newpoint //object assignment
USER DEFINED FUNCTIONS
Function definition:
 function sum(x,y) { return x + y; }
Function Constructor
 var sum = Function( x , y , return x + y; )
Function literal format (Javascript 1.2)
 var sum = Function(x,y) {return x + y;}
a function assigned to a property of an object is called a method of the
object
within the body of a function arguments[] contains an array of the
arguements
BUILT-IN FUNCTIONS
Many commonly used functions are built into the language for:
 string manipulations
 math operations
 built-in object methods
 parsing
 dynamic expression evaluation
OBJECT HIERARCHY
window
link anchor layer form applet image area
history document location toolbar
text radio button fileUpload select
textarea
password
checkbox reset
submit
option
OBJECTS
window - the current browser window
window.history - the Netscape history list
window.document - the html document currently in the
browser client area
window.location - the browser location field
window.toolbar - the browser toolbar
window.document.link - an array containing all of the links in
the document
window.document.anchor - an array of all the anchor points in
the document
OBJECTS (MORE…)
Window.document.layer - a named document layer
window.document.applet - a named java applet area
window.document.image- a named image tag
window.document.area - a named area
window.document.form - a named form or the default
form
ect, ect
A FEW EXAMPLES...
window.location = http://www.yahoo.com
 will take you to the specified URL (like a goto)
window.history.back()
 back( ) is a method on history
 will be like clicking the back button in Nav 3
 in Nav 4 will take you back to prev window
window.history.goto(1)
 takes you back to first URL in history array
THE OBJECT MODEL
It is very important to understand the object model
each object has its own properties, some of which are read only
some of which you can be set directly by assignment (as location)
each object also has a set of behaviors called methods
OBJECT MODEL
defaultValue
form
name
type
value Red- gettable and settable
=
B l u r ()
focus()
handleEvent
Select()
Text Object
HTML text tag
OBJECT EVENT HANDLERS
Most of the objects that make up the Document Object
Model respond to asynchronous, user generated events
through predefined event handlers that handle the event
and transfer control to a user provided event handling
function
Each object has particular events that they will respond to
the way you specify an event handler is by adding an
additional attribute to the HTML tag that specifies the
event and the particular handler
<input name=bt1 type=button value=ok onClick= abc( ); >
 if the button is click the function abc( ) will be run
EVENTS
onAbort
onBlur
onChange
onClick
onError
onFocus
onLoad
onMouseOut
onMouseOver
onReset
onSelect
onSubmit
onUnload
THE FORM OBJECT
Tag : <form name = n method = get|post action=URL>
Properties:
 action - action attribute of tag
 elements[ ] - creeated from like named form elements
 encoding - ENCTYPE attribute of tag
 length - length of an elements array
 method - method attribute of tag
 name - name attribute of tag
 target - target attribute of tag, where to display response page
Methods
 handleEvent( )
 reset( ) - reset all elements to initial value
 submit( ) - submit to server for processing (like submit button)
TEXT BASED OBJECTS
text
password
textarea
hidden
PROPERTIES AND METHODS
 Tag: <input name=name type=fieldtype ….>
 Properties:
 defaultValue - value attribute of tag
 form - form that this field is an element of
 name - name attribute of tag
 type - type attribute of tag (text, password, textarea, hidden)
 value - user entered value or value attribute of tag
 Methods:
 blur( ) * - unselects any selected text
 focus( ) * - readies the field for user input
 handleEvent( ) *
 select( ) * - selects the text in the field
* doesn t apply to hidden fields
ADDITIONAL EVENTS
onKeyDown =
  as soon as the key is depresses
  allows filtering of key strokes before the character is displayed
onKeyUp =
  as soon as key is released
onKeyUp = signals the end of a key down and a key up sequence
BUTTON OBJECTS
button
submit
reset
checkbox
radio
CHECKBOX OBJECT
Properties:
  checked - true if checked, false otherwise; setting doesn t cause a click
  defaultChecked - true if CHECKED attribute is present, false otherwise
  name - name attribute of the tag
  type - type attribute of the tag
  value - value attribute of the tag
Methods:
  click( ) -
  handleEvent( ) -
Additional events
  onMouseDown =
  onMouseUp =
RADIO OBJECT
one of n choices
Properties:
  checked - true if checked, false otherwise; setting doesn t cause a click
  defaultChecked - true if CHECKED attribute is present, false otherwise
  name - name attribute of the tag
  type - type attribute of the tag
  value - value attribute of the tag
Methods:
  click( ) -
  handleEvent( ) -
Additional events
  onMouseDown =
  onMouseUp =
SELECT OBJECT
Properties:
  length - number of option elements
  option[ ] - element array of the options tags
  name - name attribute of the tag
  selectedIndex - index of selected option
  options[i].defaultSelected -
  options[i].index
  options[I].selected
Methods:
  blur( ) -
  focus() -
  handleEvent( ) -
JS LIBRARIES
 jQuery
 YUI
 RGraph
jQuery is a lightweight, open-source
JavaScript library that simplifies
interaction between HTML and
JavaScript
Create HTML elements on the fly
var	
  el	
  =	
  $( <div/> )	
  
The Magic $() function
Manipulate existing DOM elements
$(window).width()	
  
The Magic $() function
Selects document elements
$( div ).hide();	
  
$( div ,	
  $( p )).hide();	
  
The Magic $() function
$(document).ready(function(){…});	
  
Fired when the document is ready for
programming.
Better use the full syntax:
$(function(){…});	
  
The Magic $() function
It may be used in case of conflict with other
frameworks.
jQuery( div );	
  
The full name of $() function is
var	
  foo	
  =	
  jQuery.noConflict();	
  
//	
  now	
  foo()	
  is	
  the	
  jQuery	
  main	
  function	
  
foo( div ).hide();	
  
Avoid $() conflict with other
frameworks
//	
  remove	
  the	
  conflicting	
  $	
  and	
  jQuery	
  
var	
  foo	
  =	
  jQuery.noConflict(true);	
  
$( p ).html( <div>Hello	
  $!</div> );	
  
	
  
//	
  escape	
  the	
  content	
  of	
  div.b	
  
$( div.a ).text($( div.b ).html());	
  
Getting and Setting Inner HTML Content
//	
  get	
  the	
  value	
  of	
  the	
  checked	
  checkbox	
  
$( input:checkbox:checked ).val();	
  
Getting and Setting Values
//	
  set	
  the	
  value	
  of	
  the	
  textbox	
  
$( :text[name= txt ] ).val( Hello );	
  
//	
  select	
  or	
  check	
  lists	
  or	
  checkboxes	
  
$( #lst ).val([ NY , IL , NS ]);	
  
Handling CSS Classes
//	
  add	
  and	
  remove	
  class	
  
$( p ).removeClass( blue ).addClass( red );	
  
//	
  add	
  if	
  absent,	
  remove	
  otherwise	
  
$( div ).toggleClass( main );	
  
//	
  test	
  for	
  class	
  existance	
  
	
  if	
  ($( div ).hasClass( main ))	
  {	
  //…	
  }	
  
//	
  just	
  show	
  
$( div ).show();	
  
//	
  reveal	
  slowly,	
  slow=600ms	
  
$( div ).show( slow );	
  
//	
  hide	
  fast,	
  fast=200ms	
  
$( div ).hide( fast );	
  
//	
  hide	
  or	
  show	
  in	
  100ms	
  $
( div ).toggle(100);	
  
Showing or Hiding Element
YUI IS AWESOME
RGRAPH
Uses the HTML5 and creates these "HTML charts"
inside the web browser using JavaScript.
We ve come in from the wilderness. Back in earlier days
we had to walk both directions, uphill in the snow.
console.log( rocks )
FIREBUG (F12)
Console
DOM Inspector
FIREBUG (F12)
FIREBUG
Breakpoints
SAFARI (CTRL +ALT + I)
INTERNET EXPLORER 8 (F12)
CHROME (CTRL + SHFT + J)
JavaScript

Mais conteúdo relacionado

Mais procurados

12. session 12 java script objects
12. session 12   java script objects12. session 12   java script objects
12. session 12 java script objectsPhúc Đỗ
 
Functional GUIs with F#
Functional GUIs with F#Functional GUIs with F#
Functional GUIs with F#Frank Krueger
 
Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#Vagif Abilov
 
Complex Data Binding
Complex Data BindingComplex Data Binding
Complex Data BindingDoncho Minkov
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of JavascriptTarek Yehia
 
09 01 tasks
09 01 tasks09 01 tasks
09 01 taskstflung
 
Software Language Design & Engineering
Software Language Design & EngineeringSoftware Language Design & Engineering
Software Language Design & EngineeringEelco Visser
 
Taming forms with React
Taming forms with ReactTaming forms with React
Taming forms with ReactGreeceJS
 
Advisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptAdvisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptdominion
 
Who killed object oriented design?
Who killed object oriented design?Who killed object oriented design?
Who killed object oriented design?Amir Barylko
 
C# Delegates, Events, Lambda
C# Delegates, Events, LambdaC# Delegates, Events, Lambda
C# Delegates, Events, LambdaJussi Pohjolainen
 
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...Doug Jones
 
C# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension MethodsC# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension MethodsMohammad Shaker
 
VB Function and procedure
VB Function and procedureVB Function and procedure
VB Function and procedurepragya ratan
 

Mais procurados (20)

12. session 12 java script objects
12. session 12   java script objects12. session 12   java script objects
12. session 12 java script objects
 
WPF Controls
WPF ControlsWPF Controls
WPF Controls
 
WPF Concepts
WPF ConceptsWPF Concepts
WPF Concepts
 
Functional GUIs with F#
Functional GUIs with F#Functional GUIs with F#
Functional GUIs with F#
 
Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#
 
Graphql, REST and Apollo
Graphql, REST and ApolloGraphql, REST and Apollo
Graphql, REST and Apollo
 
Complex Data Binding
Complex Data BindingComplex Data Binding
Complex Data Binding
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of Javascript
 
09 01 tasks
09 01 tasks09 01 tasks
09 01 tasks
 
Software Language Design & Engineering
Software Language Design & EngineeringSoftware Language Design & Engineering
Software Language Design & Engineering
 
Taming forms with React
Taming forms with ReactTaming forms with React
Taming forms with React
 
Advisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptAdvisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScript
 
Java script -23jan2015
Java script -23jan2015Java script -23jan2015
Java script -23jan2015
 
Who killed object oriented design?
Who killed object oriented design?Who killed object oriented design?
Who killed object oriented design?
 
C# Delegates, Events, Lambda
C# Delegates, Events, LambdaC# Delegates, Events, Lambda
C# Delegates, Events, Lambda
 
Javascript dom
Javascript domJavascript dom
Javascript dom
 
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
 
J Query Public
J Query PublicJ Query Public
J Query Public
 
C# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension MethodsC# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension Methods
 
VB Function and procedure
VB Function and procedureVB Function and procedure
VB Function and procedure
 

Destaque

Flex security
Flex securityFlex security
Flex securitychengalva
 
Business Interfaces using Virtual Objects, Visual-Force Forms and JavaScript
Business Interfaces using Virtual Objects, Visual-Force Forms and JavaScriptBusiness Interfaces using Virtual Objects, Visual-Force Forms and JavaScript
Business Interfaces using Virtual Objects, Visual-Force Forms and JavaScriptSalesforce Developers
 
02. input validation module v5
02. input validation module v502. input validation module v5
02. input validation module v5Eoin Keary
 
HTML5 Mullet: Forms & Input Validation
HTML5 Mullet: Forms & Input ValidationHTML5 Mullet: Forms & Input Validation
HTML5 Mullet: Forms & Input ValidationTodd Anglin
 
Web forms and server side scripting
Web forms and server side scriptingWeb forms and server side scripting
Web forms and server side scriptingsawsan slii
 
Form Validation in JavaScript
Form Validation in JavaScriptForm Validation in JavaScript
Form Validation in JavaScriptRavi Bhadauria
 
Validation rule, validation text and input masks
Validation rule, validation text and input masksValidation rule, validation text and input masks
Validation rule, validation text and input masksfizahPhd
 
HTML5 JavaScript APIs
HTML5 JavaScript APIsHTML5 JavaScript APIs
HTML5 JavaScript APIsRemy Sharp
 
TEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of WorkTEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of WorkVolker Hirsch
 

Destaque (11)

Flex security
Flex securityFlex security
Flex security
 
Business Interfaces using Virtual Objects, Visual-Force Forms and JavaScript
Business Interfaces using Virtual Objects, Visual-Force Forms and JavaScriptBusiness Interfaces using Virtual Objects, Visual-Force Forms and JavaScript
Business Interfaces using Virtual Objects, Visual-Force Forms and JavaScript
 
HTML5
HTML5HTML5
HTML5
 
02. input validation module v5
02. input validation module v502. input validation module v5
02. input validation module v5
 
HTML5 Mullet: Forms & Input Validation
HTML5 Mullet: Forms & Input ValidationHTML5 Mullet: Forms & Input Validation
HTML5 Mullet: Forms & Input Validation
 
Javascript validating form
Javascript validating formJavascript validating form
Javascript validating form
 
Web forms and server side scripting
Web forms and server side scriptingWeb forms and server side scripting
Web forms and server side scripting
 
Form Validation in JavaScript
Form Validation in JavaScriptForm Validation in JavaScript
Form Validation in JavaScript
 
Validation rule, validation text and input masks
Validation rule, validation text and input masksValidation rule, validation text and input masks
Validation rule, validation text and input masks
 
HTML5 JavaScript APIs
HTML5 JavaScript APIsHTML5 JavaScript APIs
HTML5 JavaScript APIs
 
TEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of WorkTEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of Work
 

Semelhante a JavaScript

Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsEPAM Systems
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptWalid Ashraf
 
eXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingeXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingHoat Le
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to JavascriptAnjan Banda
 
Javascript And J Query
Javascript And J QueryJavascript And J Query
Javascript And J Queryitsarsalan
 
JQuery_and_Ajax.pptx
JQuery_and_Ajax.pptxJQuery_and_Ajax.pptx
JQuery_and_Ajax.pptxAditiPawale1
 
Introduzione JQuery
Introduzione JQueryIntroduzione JQuery
Introduzione JQueryorestJump
 
presentation_jquery_ppt.pptx
presentation_jquery_ppt.pptxpresentation_jquery_ppt.pptx
presentation_jquery_ppt.pptxazz71
 
How to increase Performance of Web Application using JQuery
How to increase Performance of Web Application using JQueryHow to increase Performance of Web Application using JQuery
How to increase Performance of Web Application using JQuerykolkatageeks
 
Working With JQuery Part1
Working With JQuery Part1Working With JQuery Part1
Working With JQuery Part1saydin_soft
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)Ajay Khatri
 

Semelhante a JavaScript (20)

Unit3.pptx
Unit3.pptxUnit3.pptx
Unit3.pptx
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript Basics
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
eXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingeXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction Training
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to Javascript
 
Javascript And J Query
Javascript And J QueryJavascript And J Query
Javascript And J Query
 
JQuery_and_Ajax.pptx
JQuery_and_Ajax.pptxJQuery_and_Ajax.pptx
JQuery_and_Ajax.pptx
 
Introduzione JQuery
Introduzione JQueryIntroduzione JQuery
Introduzione JQuery
 
Lec 5
Lec 5Lec 5
Lec 5
 
J query
J queryJ query
J query
 
jQuery
jQueryjQuery
jQuery
 
Jquery
JqueryJquery
Jquery
 
Scala on Your Phone
Scala on Your PhoneScala on Your Phone
Scala on Your Phone
 
presentation_jquery_ppt.pptx
presentation_jquery_ppt.pptxpresentation_jquery_ppt.pptx
presentation_jquery_ppt.pptx
 
J query training
J query trainingJ query training
J query training
 
Wt unit 5
Wt unit 5Wt unit 5
Wt unit 5
 
How to increase Performance of Web Application using JQuery
How to increase Performance of Web Application using JQueryHow to increase Performance of Web Application using JQuery
How to increase Performance of Web Application using JQuery
 
Working With JQuery Part1
Working With JQuery Part1Working With JQuery Part1
Working With JQuery Part1
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)
 
J Query Presentation of David
J Query Presentation of DavidJ Query Presentation of David
J Query Presentation of David
 

Último

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Último (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

JavaScript

  • 1.
  • 2. WHAT WE RE GOING TO DO  Pretest & Review of Javascript Basics  Digging in –  Event Handling  HTML Forms Validation  JS Libraries  Testing/Debugging
  • 3.
  • 4. WHAT IS JAVASCRIPT Object based (not object oriented) programming language  very limited object creation  a set of pre-defined objects associated with  HTML document structure  many HTML tags constitute JS Objects  Browser functionality  provides a limited API to Browser functionality
  • 5. JAVASCRIPT…JAVA ? There is no relationship other than the fact that Java and JavaScript resemble each other (and C++) syntactically JavaScript is pretty much the de-facto standard for client-side scripting
  • 6. WHAT CAN IT BE USED FOR Some pretty amazing things….  Text animation  graphic animation  simple browser based application  HTML forms submission  client-side forms data validation (relieving the server of this task)  web site navigation
  • 7. PUTTING JAVASCRIPT INTO YOUR HTML in an external file  collect commonly used functions together into external function libraries on the server  added benefit of privacy from all but the most curious users in-line with your HTML as an expression for an HTML tag attribute within some HTML tags as Event Handlers
  • 8. <SCRIPT> <SCRIPT LANGUAGE= JavaScript > <!-- start hiding code from old browsers> Your Javascript Code Goes Here // Stop Hiding code --> </SCRIPT>
  • 9. PROGRAMMING FUNDAMENTALS Value Types  String Sample  Number 2.52 , 5 , .5  Boolean true, false  Null null  Object - all properties and methods belonging to the object or array  Function - a function definition
  • 10. VARIABLES Naming  start with alpha followed by alphameric (and _) Creating  use the var keyword  var myName  definition and initialization can be combined  var myName = Dick
  • 11. ARRAYS One dimensional arrays  var myarray = new Array( ) //empty array  var myarray1 = new Array(10) // 10 elements  var myarray2 = new Array(2,4,6) // 3 elements initialized to 2, 4, and 6 respectively 0 based - myarray[0] is first element
  • 12. USER DEFINED OBJECTS Implemented as associative arrays  var point = new Object() // empty object  point.x = 5 ; point.y = 3; // no longer empty  var newpoint = {x:4 , y:5} // object literal form  var anotherpoint = new Object( )  anotherpoint = newpoint //object assignment
  • 13. USER DEFINED FUNCTIONS Function definition:  function sum(x,y) { return x + y; } Function Constructor  var sum = Function( x , y , return x + y; ) Function literal format (Javascript 1.2)  var sum = Function(x,y) {return x + y;} a function assigned to a property of an object is called a method of the object within the body of a function arguments[] contains an array of the arguements
  • 14. BUILT-IN FUNCTIONS Many commonly used functions are built into the language for:  string manipulations  math operations  built-in object methods  parsing  dynamic expression evaluation
  • 15. OBJECT HIERARCHY window link anchor layer form applet image area history document location toolbar text radio button fileUpload select textarea password checkbox reset submit option
  • 16. OBJECTS window - the current browser window window.history - the Netscape history list window.document - the html document currently in the browser client area window.location - the browser location field window.toolbar - the browser toolbar window.document.link - an array containing all of the links in the document window.document.anchor - an array of all the anchor points in the document
  • 17. OBJECTS (MORE…) Window.document.layer - a named document layer window.document.applet - a named java applet area window.document.image- a named image tag window.document.area - a named area window.document.form - a named form or the default form ect, ect
  • 18. A FEW EXAMPLES... window.location = http://www.yahoo.com  will take you to the specified URL (like a goto) window.history.back()  back( ) is a method on history  will be like clicking the back button in Nav 3  in Nav 4 will take you back to prev window window.history.goto(1)  takes you back to first URL in history array
  • 19. THE OBJECT MODEL It is very important to understand the object model each object has its own properties, some of which are read only some of which you can be set directly by assignment (as location) each object also has a set of behaviors called methods
  • 20. OBJECT MODEL defaultValue form name type value Red- gettable and settable = B l u r () focus() handleEvent Select() Text Object HTML text tag
  • 21.
  • 22. OBJECT EVENT HANDLERS Most of the objects that make up the Document Object Model respond to asynchronous, user generated events through predefined event handlers that handle the event and transfer control to a user provided event handling function Each object has particular events that they will respond to the way you specify an event handler is by adding an additional attribute to the HTML tag that specifies the event and the particular handler <input name=bt1 type=button value=ok onClick= abc( ); >  if the button is click the function abc( ) will be run
  • 24.
  • 25. THE FORM OBJECT Tag : <form name = n method = get|post action=URL> Properties:  action - action attribute of tag  elements[ ] - creeated from like named form elements  encoding - ENCTYPE attribute of tag  length - length of an elements array  method - method attribute of tag  name - name attribute of tag  target - target attribute of tag, where to display response page Methods  handleEvent( )  reset( ) - reset all elements to initial value  submit( ) - submit to server for processing (like submit button)
  • 27. PROPERTIES AND METHODS  Tag: <input name=name type=fieldtype ….>  Properties:  defaultValue - value attribute of tag  form - form that this field is an element of  name - name attribute of tag  type - type attribute of tag (text, password, textarea, hidden)  value - user entered value or value attribute of tag  Methods:  blur( ) * - unselects any selected text  focus( ) * - readies the field for user input  handleEvent( ) *  select( ) * - selects the text in the field * doesn t apply to hidden fields
  • 28. ADDITIONAL EVENTS onKeyDown =   as soon as the key is depresses   allows filtering of key strokes before the character is displayed onKeyUp =   as soon as key is released onKeyUp = signals the end of a key down and a key up sequence
  • 30. CHECKBOX OBJECT Properties:   checked - true if checked, false otherwise; setting doesn t cause a click   defaultChecked - true if CHECKED attribute is present, false otherwise   name - name attribute of the tag   type - type attribute of the tag   value - value attribute of the tag Methods:   click( ) -   handleEvent( ) - Additional events   onMouseDown =   onMouseUp =
  • 31. RADIO OBJECT one of n choices Properties:   checked - true if checked, false otherwise; setting doesn t cause a click   defaultChecked - true if CHECKED attribute is present, false otherwise   name - name attribute of the tag   type - type attribute of the tag   value - value attribute of the tag Methods:   click( ) -   handleEvent( ) - Additional events   onMouseDown =   onMouseUp =
  • 32. SELECT OBJECT Properties:   length - number of option elements   option[ ] - element array of the options tags   name - name attribute of the tag   selectedIndex - index of selected option   options[i].defaultSelected -   options[i].index   options[I].selected Methods:   blur( ) -   focus() -   handleEvent( ) -
  • 33.
  • 35. jQuery is a lightweight, open-source JavaScript library that simplifies interaction between HTML and JavaScript
  • 36. Create HTML elements on the fly var  el  =  $( <div/> )   The Magic $() function
  • 37. Manipulate existing DOM elements $(window).width()   The Magic $() function
  • 38. Selects document elements $( div ).hide();   $( div ,  $( p )).hide();   The Magic $() function
  • 39. $(document).ready(function(){…});   Fired when the document is ready for programming. Better use the full syntax: $(function(){…});   The Magic $() function
  • 40. It may be used in case of conflict with other frameworks. jQuery( div );   The full name of $() function is
  • 41. var  foo  =  jQuery.noConflict();   //  now  foo()  is  the  jQuery  main  function   foo( div ).hide();   Avoid $() conflict with other frameworks //  remove  the  conflicting  $  and  jQuery   var  foo  =  jQuery.noConflict(true);  
  • 42. $( p ).html( <div>Hello  $!</div> );     //  escape  the  content  of  div.b   $( div.a ).text($( div.b ).html());   Getting and Setting Inner HTML Content
  • 43. //  get  the  value  of  the  checked  checkbox   $( input:checkbox:checked ).val();   Getting and Setting Values //  set  the  value  of  the  textbox   $( :text[name= txt ] ).val( Hello );   //  select  or  check  lists  or  checkboxes   $( #lst ).val([ NY , IL , NS ]);  
  • 44. Handling CSS Classes //  add  and  remove  class   $( p ).removeClass( blue ).addClass( red );   //  add  if  absent,  remove  otherwise   $( div ).toggleClass( main );   //  test  for  class  existance    if  ($( div ).hasClass( main ))  {  //…  }  
  • 45. //  just  show   $( div ).show();   //  reveal  slowly,  slow=600ms   $( div ).show( slow );   //  hide  fast,  fast=200ms   $( div ).hide( fast );   //  hide  or  show  in  100ms  $ ( div ).toggle(100);   Showing or Hiding Element
  • 47. RGRAPH Uses the HTML5 and creates these "HTML charts" inside the web browser using JavaScript.
  • 48.
  • 49.
  • 50. We ve come in from the wilderness. Back in earlier days we had to walk both directions, uphill in the snow. console.log( rocks )
  • 56. CHROME (CTRL + SHFT + J)