SlideShare a Scribd company logo
1 of 12
Principles of Program Design:
Problem Solving with JavaScript
Using Existing JavaScript Objects
• Types of objects
– Document (refers to the Web page where the text in HTML are
displayed. This object is instantiated automatically when an HTML file
is open in a browser.
– Array – (will cover later on – for storing multiple values in a single
variable)
– Date - (for retrieving and using dates - Date objects are static, not
dynamic. The computer time is ticking, but date objects, once created,
are not.)
– Boolean - (for objects that can be classified as true or false)
– Math – (allows you to perform mathematical tasks on numbers.)
2
– Documents are instantiated automatically when an HTML file is opened
in a Web Browser.
– When a web page is loaded, the browser creates a Document Object
Model of the page.
– The DOM is a hierarchy of elements belonging to a document
– Example – the <head> and <body> sections are the doc’s major
sections.
– There are lots of other objects defined in the DOM – i.e. window, button
and form objects.
• Static properties
– One value for the whole class
– Example: The constant value PI for the Math object
• Static methods
– Can be called independently of a separate object
3
Documents and the DOM ( Document Object Model)
Numbers and Math
Image taken from: http://www.stsd.org/webpages/cyurconic/news.cfm?subpage=67815
Math and Numbers
• JavaScript has only one type of number.
• Numbers can be written with, or without, decimals:
• Math allows you to perform mathematical tasks on numbers and
provides programmers with numerous built-in methods.
• Math is not a constructor. All properties/methods of Math can be
called by using Math as an object, without creating it.
• Check out the various methods in the w3schools links provided
Image taken from:
http://www.amazingclassroom.com/
Image taken from:
netperusal.com
www.netpursual.com
String Methods
Image taken from: http://papiervalise.typepad.com/scissor_variations/2012/08/diy-ombre-string.html
Important String Stuff
• A JavaScript string stores a series of characters like "John Doe".
• A string can be any text inside double or single quotes:
• Remember with strings the first letter is at index position 0.
• The last letter is always at the length of the string -1.
• The middle letter is always at the length of the
string /2
School
012345
There are a gazillion built-in String Methods – some are listed and
explained here: http://www.w3schools.com/jsref/jsref_obj_string.asp
Graphical User Interfaces
• Graphical user interface (GUI)
– Resembles a paper form in which users enter data
8
• Creating GUI form
– Created with HTML tags in <body> section
– Two attributes:
• name assigns a name to the form
• action manipulates user’s entry
• Elements of a form
– Buttons, text boxes, radio buttons, check boxes and other
graphical items used to interact with a program
– You don’t need the script section when creating a form – each
element is created with an <input> tage and all are empty
• Tag ends with />
Graphical User Interfaces (cont’d.)
• Radio buttons
– Group of circular buttons
– Used to select an item from a group
– Type value: “radio”
– name attribute of all buttons must be identical
• Ensures only one is selected
– value attribute holds text
• Can be passed as argument when action is taken
– Label appears as text after the end of the <input>
tag
9
Graphical User Interfaces (cont’d.)
• Text boxes- gives the user a place to enter text and
to give the programmer a label with text that can be
changed.
– Type value: “text”
– Value of name attribute is different for each box
– Can be set to read-only
– value attribute can be assigned and displayed as
prompt
– size attribute can be specified
• Limits number of characters
10
• Buttons – used to initiate an action
– Type value: “button”
– Value of name attribute is different for each button
– value attribute specifies displayed text
How to create a form:
• Check out the example of how to create a form with
radio buttons and text boxes on pgs 110 – 111 in
your textbook.
• In this form, when you click one radio button, the
others are deselected.
• Some text boxes let you type in them, some don’t
• If you don’t want the user to be able to enter text in
a box, you will make it read only. (readonly = “true”)
11
12
Your task in this lesson (Hands-on Activity 3-4) is to create a form for use on a
Flower shop’s Web site.
•The form should have a single text box for the user to enter his or her name.
•Under the text box should be a group of radio buttons for 3 different types of
flowers: Roses, Carnations and Daisies.
•Below the radio buttons should be a button labeled Request Info, with a read
only text box under it for displaying a thank you to the user for his/her request
for information.
At this point, this program doesn’t need and functions or onclick attributes for
the graphical elements – Just the form – and your comments :-) Could look
something like this:
Image source: http://www.wpclipart.com/

More Related Content

What's hot

What's hot (20)

Java intro
Java introJava intro
Java intro
 
Intro to JavaScript - Thinkful LA, June 2017
Intro to JavaScript - Thinkful LA, June 2017Intro to JavaScript - Thinkful LA, June 2017
Intro to JavaScript - Thinkful LA, June 2017
 
Java
JavaJava
Java
 
java-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaijava-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbai
 
Jdbcconnectivitytojava 190804164056
Jdbcconnectivitytojava 190804164056Jdbcconnectivitytojava 190804164056
Jdbcconnectivitytojava 190804164056
 
Jdbc connectivity to java
Jdbc connectivity to javaJdbc connectivity to java
Jdbc connectivity to java
 
Functional js class
Functional js classFunctional js class
Functional js class
 
[OOP - Lec 06] Classes and Objects
[OOP - Lec 06] Classes and Objects[OOP - Lec 06] Classes and Objects
[OOP - Lec 06] Classes and Objects
 
JavaScript operators
JavaScript operatorsJavaScript operators
JavaScript operators
 
Intro to javascript (6:27)
Intro to javascript (6:27)Intro to javascript (6:27)
Intro to javascript (6:27)
 
MTA understanding java script and coding essentials
MTA understanding java script and coding essentialsMTA understanding java script and coding essentials
MTA understanding java script and coding essentials
 
Thinkful - Intro to JavaScript
Thinkful - Intro to JavaScriptThinkful - Intro to JavaScript
Thinkful - Intro to JavaScript
 
[OOP - Lec 03] Programming Paradigms
[OOP - Lec 03] Programming Paradigms[OOP - Lec 03] Programming Paradigms
[OOP - Lec 03] Programming Paradigms
 
Intro to javascript (6:19)
Intro to javascript (6:19)Intro to javascript (6:19)
Intro to javascript (6:19)
 
MVC and Entity Framework 4
MVC and Entity Framework 4MVC and Entity Framework 4
MVC and Entity Framework 4
 
Learn VB.NET at ASIT
Learn VB.NET at ASITLearn VB.NET at ASIT
Learn VB.NET at ASIT
 
ASP.NET MVC and Entity Framework 4
ASP.NET MVC and Entity Framework 4ASP.NET MVC and Entity Framework 4
ASP.NET MVC and Entity Framework 4
 
Intro to ember.js
Intro to ember.jsIntro to ember.js
Intro to ember.js
 
Java Introduction Workshop Day 2
Java Introduction Workshop Day 2 Java Introduction Workshop Day 2
Java Introduction Workshop Day 2
 
Expression language
Expression languageExpression language
Expression language
 

Similar to U2A3

Similar to U2A3 (20)

WEB TECHNOLOGY Unit-4.pptx
WEB TECHNOLOGY Unit-4.pptxWEB TECHNOLOGY Unit-4.pptx
WEB TECHNOLOGY Unit-4.pptx
 
Evaluation of DOM Tree Similarities - Thesis Presentation
Evaluation of DOM Tree Similarities - Thesis PresentationEvaluation of DOM Tree Similarities - Thesis Presentation
Evaluation of DOM Tree Similarities - Thesis Presentation
 
Webdev bootcamp
Webdev bootcampWebdev bootcamp
Webdev bootcamp
 
Web technologies-course 09.pptx
Web technologies-course 09.pptxWeb technologies-course 09.pptx
Web technologies-course 09.pptx
 
Easy javascript
Easy javascriptEasy javascript
Easy javascript
 
Dom date and objects and event handling
Dom date and objects and event handlingDom date and objects and event handling
Dom date and objects and event handling
 
Ddpz2613 topic9 java
Ddpz2613 topic9 javaDdpz2613 topic9 java
Ddpz2613 topic9 java
 
Lec02
Lec02Lec02
Lec02
 
srt311 Project2
srt311 Project2srt311 Project2
srt311 Project2
 
Dom
DomDom
Dom
 
Web Technology Part 3
Web Technology Part 3Web Technology Part 3
Web Technology Part 3
 
Customize it! Make IBM Connections look your way
Customize it! Make IBM Connections look your way Customize it! Make IBM Connections look your way
Customize it! Make IBM Connections look your way
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Web forms and html (lect 4)
Web forms and html (lect 4)Web forms and html (lect 4)
Web forms and html (lect 4)
 
Dom structure
Dom structureDom structure
Dom structure
 
Instagram filters
Instagram filters Instagram filters
Instagram filters
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
Learn javascript easy steps
Learn javascript easy stepsLearn javascript easy steps
Learn javascript easy steps
 
6867389.ppt
6867389.ppt6867389.ppt
6867389.ppt
 
6867389.ppt
6867389.ppt6867389.ppt
6867389.ppt
 

More from pfefferteacher

More from pfefferteacher (6)

Standard form solve equations
Standard form solve equationsStandard form solve equations
Standard form solve equations
 
Croatia
CroatiaCroatia
Croatia
 
Travel slide share
Travel slide shareTravel slide share
Travel slide share
 
Grade bumps
Grade bumpsGrade bumps
Grade bumps
 
Grade bumps
Grade bumpsGrade bumps
Grade bumps
 
How to check your grades
How to check your gradesHow to check your grades
How to check your grades
 

Recently uploaded

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
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
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
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
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
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
 

Recently uploaded (20)

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
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
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
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
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
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
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
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🔝
 
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
 

U2A3

  • 1. Principles of Program Design: Problem Solving with JavaScript
  • 2. Using Existing JavaScript Objects • Types of objects – Document (refers to the Web page where the text in HTML are displayed. This object is instantiated automatically when an HTML file is open in a browser. – Array – (will cover later on – for storing multiple values in a single variable) – Date - (for retrieving and using dates - Date objects are static, not dynamic. The computer time is ticking, but date objects, once created, are not.) – Boolean - (for objects that can be classified as true or false) – Math – (allows you to perform mathematical tasks on numbers.) 2
  • 3. – Documents are instantiated automatically when an HTML file is opened in a Web Browser. – When a web page is loaded, the browser creates a Document Object Model of the page. – The DOM is a hierarchy of elements belonging to a document – Example – the <head> and <body> sections are the doc’s major sections. – There are lots of other objects defined in the DOM – i.e. window, button and form objects. • Static properties – One value for the whole class – Example: The constant value PI for the Math object • Static methods – Can be called independently of a separate object 3 Documents and the DOM ( Document Object Model)
  • 4. Numbers and Math Image taken from: http://www.stsd.org/webpages/cyurconic/news.cfm?subpage=67815
  • 5. Math and Numbers • JavaScript has only one type of number. • Numbers can be written with, or without, decimals: • Math allows you to perform mathematical tasks on numbers and provides programmers with numerous built-in methods. • Math is not a constructor. All properties/methods of Math can be called by using Math as an object, without creating it. • Check out the various methods in the w3schools links provided Image taken from: http://www.amazingclassroom.com/ Image taken from: netperusal.com www.netpursual.com
  • 6. String Methods Image taken from: http://papiervalise.typepad.com/scissor_variations/2012/08/diy-ombre-string.html
  • 7. Important String Stuff • A JavaScript string stores a series of characters like "John Doe". • A string can be any text inside double or single quotes: • Remember with strings the first letter is at index position 0. • The last letter is always at the length of the string -1. • The middle letter is always at the length of the string /2 School 012345 There are a gazillion built-in String Methods – some are listed and explained here: http://www.w3schools.com/jsref/jsref_obj_string.asp
  • 8. Graphical User Interfaces • Graphical user interface (GUI) – Resembles a paper form in which users enter data 8 • Creating GUI form – Created with HTML tags in <body> section – Two attributes: • name assigns a name to the form • action manipulates user’s entry • Elements of a form – Buttons, text boxes, radio buttons, check boxes and other graphical items used to interact with a program – You don’t need the script section when creating a form – each element is created with an <input> tage and all are empty • Tag ends with />
  • 9. Graphical User Interfaces (cont’d.) • Radio buttons – Group of circular buttons – Used to select an item from a group – Type value: “radio” – name attribute of all buttons must be identical • Ensures only one is selected – value attribute holds text • Can be passed as argument when action is taken – Label appears as text after the end of the <input> tag 9
  • 10. Graphical User Interfaces (cont’d.) • Text boxes- gives the user a place to enter text and to give the programmer a label with text that can be changed. – Type value: “text” – Value of name attribute is different for each box – Can be set to read-only – value attribute can be assigned and displayed as prompt – size attribute can be specified • Limits number of characters 10 • Buttons – used to initiate an action – Type value: “button” – Value of name attribute is different for each button – value attribute specifies displayed text
  • 11. How to create a form: • Check out the example of how to create a form with radio buttons and text boxes on pgs 110 – 111 in your textbook. • In this form, when you click one radio button, the others are deselected. • Some text boxes let you type in them, some don’t • If you don’t want the user to be able to enter text in a box, you will make it read only. (readonly = “true”) 11
  • 12. 12 Your task in this lesson (Hands-on Activity 3-4) is to create a form for use on a Flower shop’s Web site. •The form should have a single text box for the user to enter his or her name. •Under the text box should be a group of radio buttons for 3 different types of flowers: Roses, Carnations and Daisies. •Below the radio buttons should be a button labeled Request Info, with a read only text box under it for displaying a thank you to the user for his/her request for information. At this point, this program doesn’t need and functions or onclick attributes for the graphical elements – Just the form – and your comments :-) Could look something like this: Image source: http://www.wpclipart.com/