 Collection of statements that can be invoked as a unit  Can take parameters  Can be used multiple times  Can call without knowing what they do or.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

The Web Warrior Guide to Web Design Technologies
 Inside attributes like onclick  As a section of code in the body  Only special cases  As a function in a separate file  Can link to it like the.
Javascript Client-side scripting. Up to now  We've seen a little about how to control  content with HTML  presentation with CSS  Javascript is a language.
29 November JavaScript: Arrays and Iterations Functions.
Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
JAVASCRIPT TIPS. REMEMBER JAVASCRIPT IS VERY, VERY CASE SENSITIVE.
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
JavaScript Teppo Räisänen LIIKE/OAMK HTML, CSS, JavaScript HTML defines the structure CSS defines the layout JavaScript is used for scripting It.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
SYST Web Technologies SYST Web Technologies Lesson 6 – Intro to JavaScript.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
Process of interface design Instant Saxon XML/XSLT to JavaScript Design process, sampling Class time for work on user projects Homework: complete user.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
JavaScript - A Web Script Language Fred Durao
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
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, Fourth Edition
Introduction To JavaScript. Putting it Together (page 11) All javascript must go in-between the script tags. All javascript must go in-between the script.
1 JavaScript Part 3. Functions Allow the user to decide when a particular script should be run by the browser in stead of running as long as the page.
JavaScript VARIABLES AND DATA TYPES. OUTPUT WITHOUT ALERT OR FORM CONSOLE.LOG();
Introduction to JavaScript CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also.
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.
Event Handling (the right way). A Simple Web Page Events - Summary The web page looks like this:
JavaScript Functions. CSS Inheritance Which formatting applies? x y z input { display: block; } input.pref { background:red; } If you have a selector.
Understanding JavaScript and Coding Essentials Lesson 8.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
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.
JavaScript and Ajax (JavaScript Functions) Week 5 Web site:
1 Lesson 6 Introducing JavaScript HTML and JavaScript BASICS, 4 th Edition.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
Week-12 (Lecture-1) Cascading Style Sheets (CSS): describe how documents are presented on screens. Types of Style Sheets: External Style Sheet - Define.
Week 3: Introduction to Javascript
Chapter 6 JavaScript: Introduction to Scripting
>> JavaScript: Location, Functions and Objects
Learning to Program D is for Digital.
CHAPTER 4 CLIENT SIDE SCRIPTING PART 3 OF 3
JavaScript.
Variables and Data Types
JavaScript functions.
JavaScript Functions.
JavaScript.
JavaScript Forms Adding User Input.
JavaScript an introduction.
Web Systems Development (CSC-215)
DHTML Javascript Internet Technology.
Console.
Javascript: variables and parameters
JavaScript Functions.
WEB PROGRAMMING JavaScript.
DHTML Javascript Internet Technology.
Reviewing key concepts
Variables and Data Types
Writing to a PAGE.
An Introduction to JavaScript
For this assignment, copy and past the XHTML to a notepad file with the .html extension. Then add the code I ask for to complete the problems.
Introduction to Programming and JavaScript
JavaScript: Introduction to Scripting
JavaScript functions.
Writing to the Page Formatting Forms
CIS 136 Building Mobile Apps
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.
Presentation transcript:

 Collection of statements that can be invoked as a unit  Can take parameters  Can be used multiple times  Can call without knowing what they do or how

HTML

JAVASCRIPT

HTMLJAVASCRIPT

HTMLJAVASCRIPT

HTMLJAVASCRIPT

HTMLJAVASCRIPT

Parameters Return Function Building Up Function Capabilities

Move the onclick work into a function

Function

function name() { stmt; }

Let the function work on any data

Parameters Function

function name(parm) { stmt; }

 Name is a placeholder  Can be used anywhere in a function  Can be used as many times as you want  Can not change it  MUST supply value when call  Can be different every time

 Just a special type of variable  Something that you hand to the function  Q: Many users: how do you name?  A: Give it its OWN names to use locally  Q: How do you match up?  A: By POSITION

HTML JAVASCRIPT (FUNCTION.JS) function doit (a,b) { var c = a*b); alert(“product is ”+c); }

HTMLJS mypet(‘cow’); mypet(‘dog’); function mypet(pet) { alert(‘my pet: ‘+pet); }

 Order matters  Need different names

HTMLJS mypet(‘Mutt’,’Jeff’); mypet(‘Jeff’,’Mutt’); function taller(big,small) { alert (big+’ is taller than ‘+ small); }

Let the result be placed anywhere

Parameters Return Function

 Use the function as a value  form.field.value = function(parm1, parm2);  difference = subtract(minuhend,subtrahend);  Contrast with  alert(string);  append(form.field.value,’end’);

return (value);  Want to get information BACK to HTML  With a return, the function has a VALUE  Can be used anywhere you can use a constant or variable  Alert  Assignment statement

HTML JAVASCRIPT (FUNCTION.JS) function doit (a,b) { var c = a*b); return(c); }

 Need to define  Inputs  Outputs  What to do

 These are the parameters  Order matters  Need a way to reference them  Position 1, position 2, …  Cubby holes  Better to use meaningful names  Each name is just a pointer to the cubby hole

 Use a RETURN statement  A write-once cubby hole  Only way to access is the RETURN statement  Once you set it, the function is ended  Can have a simple value or more (e.g., concatenating strings)

 Series of statements: the recipe  Assignment statements  Function calls  Can use  Literals (5, “ “)  parameters  Specially defined locations ( variables )

 Like CSS, can be inline or a separate file  Like CSS, an external file is considered better practice  Like CSS, link to it from the head section

Myscript.js JavaScript option in komodo note that it’s an empty file but it can help you do NOT include the script tag

HTML JAVASCRIPT (FUNCTION.JS) function doit () { alert(“Hi!”); }