Enhancing Websites with JavaScript. How Do You Give Directions? Lots of details? Specific steps? Just the gist? What language?

Slides:



Advertisements
Similar presentations
Al-Karma Language School Computer Department Prep. 3.
Advertisements

1 Javascrbipt Intro Javascript (or js) is a programming language. Interpreted, not compiled. Not the same as java, but, similar. Use tags to use. Object-oriented.
JavaScript 101 Lesson 01: Writing Your First JavaScript.
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
16/19/2015CS120 The Information Era CS120 The Information Era Chapter 5 – Advanced HTML TOPICS: Introduction to Web Page Forms and Introductory Javascript.
Information Technology Center Hany Abdelwahab Computer Specialist.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
JavaScript Lesson 1 TBE 540. Prerequisites  Before beginning this lesson, the learner must be able to… Create a basic web page using a text editor and/or.
JavaScript with Input & Output Step 1: Use tags JavaScript Template.
CIS101 Introduction to Computing Week 12 Spring 2004.
* Just the gist? * Lots of details? * Specific steps? * What language ?
JavaScript Switch Statement. Switch JavaScript Switch Statement If you have a lot of conditions, you can use a switch statement instead of an if…elseif…
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
HTML Forms What is a form.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
Adding JavaScript (<script tag>)
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Javascript and Basic Programming Concepts. What is a Program? A program is a specific set of instructions written in a computer language to perform a.
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
Week 9 PHP Cookies and Session Introduction to JavaScript.
Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and check boxes using HTML Add a pull-down.
Chapter 4 JavaScript and Dynamic Web pages. Objectives Static Web pages Dynamic Web pages JavaScript Variables Assignments. JavaScript Functions –(prompt(“”,””)
Objective Static vs. Dynamic Web pages. Variables. Assignments. JavaScript Hierarchy of Objects JavaScript Functions (prompt(“”,””) Document.write(“”)
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Dynamic Web Pages & JavaScript. Dynamic Web Pages Dynamic = Change Dynamic Web Pages are web pages that change. More than just moving graphics around.
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
Button and Textbox. Input  Input objects are used to obtain input from the user viewing the webpage. They allow the user to interact with the Web. 
* Just the gist? * Lots of details? * Specific steps? * What language ?
1 JavaScript
Input & Output Functions JavaScript is special from other languages because it can accept input and produce output on the basis of that input in the same.
Introduction to JavaScript CS101 Introduction to Computing.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
IS2802 Introduction to Multimedia Applications for Business Lecture 3: JavaScript and Functions Rob Gleasure
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
JavaScript Challenges Answers for challenges
© 2007 D. J. ForemanJS-1 A Light Introduction for Non-programmers JavaScript for Beginners.
 2003 Prentice Hall, Inc. All rights reserved. Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
Basic Webpage Design HTML Forms. Objectives Learn how to use HTML to create a form. Explain the concept of forms Know the difference of GET and POST Discuss.
Javascript Overview. What is Javascript? May be one of the most popular programming languages ever Runs in the browser, not on the server All modern browsers.
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
Web Forms. Web Forms: A form allows our web visitors to submit information to us. Some examples uses for forms are to let the web user contact us, fill.
HTML Elements: Forms and Controls Chapter 9 B. Ramamurthy.
Lesson 5 Introduction to HTML Forms. Lesson 5 Forms A form is an area that can contain form elements. Form elements are elements that allow the user to.
JavaScript Part 1 Introduction to scripting The ‘alert’ function.
CHAPTER 10 JAVA SCRIPT.
HTML & teh internets.
Donna J. Kain, Clarkson University
Section 17.1 Section 17.2 Add an audio file using HTML
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Chapter 7 - JavaScript: Introduction to Scripting
Event Driven Programming & User Defined Functions
JavaScript: Introduction to Scripting
Programming in JavaScript
CS105 Introduction to Computer Concepts
Computer communications
Chapter 7 - JavaScript: Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
Web Programming– UFCFB Lecture 13
Web Programming and Design
This is an introduction to JavaScript using the examples found at the CIS17 website. In previous examples I specified language = Javascript, instead of.
CS105 Introduction to Computer Concepts JavaScript
Chapter 7 - JavaScript: Introduction to Scripting
Presentation transcript:

Enhancing Websites with JavaScript

How Do You Give Directions? Lots of details? Specific steps? Just the gist? What language?

Giving Directions With JavaScript Just one way of talking to a computer. Not related to Java Useful for games and widgets Useful for websites

Just the Basics Format Output Variables Functions Input Conditionals

Format Goes in head or body or another tag or another file Uses tags Need to specify the language in the tag

Output Statements that tell the computer to print something somewhere. document.write(WhateverYouWantToPrint)

Output Example First JavaScript page document.write(" Hello World ");

Resulting Webpage

Hello Part 2 First JavaScript page document.write(" Hello World "); document.write(" Or Whoever Is Listening ");

And the Webpage

Why Use JavaScript? What if we wanted to calculate 2*3? 2*3=2*3

And the Resulting Webpage

JavaScript Solution First JavaScript page answer = 2*3; document.write("2*3="+ answer);

Resulting JavaScript Webpage

Another Calculating Example First JavaScript page timesanswer = 2*3; plusanswer = 2+3; document.write("2*3="+ timesanswer + " and 2+3=" + plusanswer);

Along With the Webpage

What if We Want Three Calculations? First JavaScript page answer = 2*3; document.write("2*3="+ answer + " "); answer = 10*5; document.write("10*5="+ answer + " "); answer = 1024*4; document.write("1024*4="+ answer + " ");

What if 100’s of Calculations? Or lots of something else beside calculations? Functions are an answer! Functions can go in the head and be called from the body.

Example Using a Function to Calculate First JavaScript page function calculateAnswers(number1,number2){ timesanswer = number1*number2; document.write(number1 + "*" + number2 + "=" + timesanswer); document.write(" "); } calculateAnswers(2,3); calculateAnswers(10,5); calculateAnswers(1024,4);

First Function Webpage

Not Much Fun Without User Input Can use tags Inside the form tags use tag Some types of input  Text  Button  Checkbox Types have attributes such as size and name Can respond back to the user with an Alert (tiny popup window)

Sample User Input Page First JavaScript page function calculateAnswers(number1,number2){ timesanswer = number1*number2; alert("The answer is: " + timesanswer); } Enter two numbers to be multiplied: Number1: Number2:

Resulting Webpage Check it out at html html

What About Conditions? If something happens, do something, otherwise do something else... That is the computer can do different things based on some decision.

Try Out and Example Without Decision Making The following website does division of two numbers. Try it out. Be sure to try and divide by html 2.html

How to do a JavaScript Decision If (something happens){ take some action } else{ take a different action }

Something Happens? Symbolmeaning ==Equal to, and yes that is two = signs right next to each other !=Not equal to >Greater than <Less than >=Greate than or equal to <=Less than or equal to

Example With Decision Making Check out 3.html 3.html Be sure to view the page source to see the condition.

More Examples Calculate the average of three test scores Read info and send if over Vote with alert after each button click Vote with alert only after announce the winner button is clicked