JavaScript Functions. CSS Inheritance Which formatting applies? x y z input { display: block; } input.pref { background:red; } If you have a selector.

Slides:



Advertisements
Similar presentations
Copyright © 2002 W. A. Tucker1 Chapter 3 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Advertisements

The Web Warrior Guide to Web Design Technologies
JavaScript Part for Repetition Statement for statement Cpecifies each of the items needed for counter-controlled repetition with a control variable.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project.
28-Jun-15 Using Objects. 2 Overview In this presentation we will discuss: Classes and objects Methods for objects Printing results.
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.
29-Jun-15 Using Objects. 2 Classes and objects The type of an object is the class that describes that object If we say int count, the type of count is.
JAVASCRIPT TIPS. REMEMBER JAVASCRIPT IS VERY, VERY CASE SENSITIVE.
Basic Input/Output and Variables Ethan Cerami New York
Business Computer Information Systems Microsoft Office XP Access Review Lessons 1 through 5.
CMSC 104, Version 8/061L18Functions1.ppt Functions, Part 1 of 4 Topics Using Predefined Functions Programmer-Defined Functions Using Input Parameters Function.
Using Object-Oriented JavaScript CST 200- JavaScript 4 –
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Programming.
Introduction to Python
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Microsoft ® Access ® 2010 Training Create Queries for a New Database If a yellow security bar appears at the top of the screen in PowerPoint, click Enable.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Functions.
Agenda Review C++ Library Functions Review User Input Making your own functions Exam #1 Next Week Reading: Chapter 3.
CS 177 Week 4 Recitation Slides Variables, Files and Functions.
Functions. Built-in functions You’ve used several functions already >>> len("ATGGTCA")‏ 7 >>> abs(-6)‏ 6 >>> float("3.1415")‏ >>>
David Stotts Computer Science Department UNC Chapel Hill.
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
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.
1 FUNCTIONS - I Chapter 5 Functions help us write more complex programs.
XP Tutorial 8 Adding Interactivity with ActionScript.
JavaScript: The First Parts Part One Douglas Crockford Yahoo! Inc.
CSCE 102 – Chapter 11 (Performing Calculations) CSCE General Applications Programming Benito Mendoza Benito Mendoza 1 By Benito Mendoza.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
1 Printing in Python Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external files.
Introduction to LISP Atoms, Lists Math. LISP n LISt Processing n Function model –Program = function definition –Give arguments –Returns values n Mathematical.
JavaScript VARIABLES AND DATA TYPES. OUTPUT WITHOUT ALERT OR FORM CONSOLE.LOG();
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.
Tutorial 11 1 JavaScript Operators and Expressions.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Midterm Review Tami Meredith. Primitive Data Types byte, short, int, long Values without a decimal point,..., -1, 0, 1, 2,... float, double Values with.
JavaScript and Ajax (JavaScript Functions) Week 5 Web site:
Expressions and Data Types Professor Robin Burke.
Dale Roberts CSCI N305 Functions Declarations Department of Computer and Information Science, School of Science, IUPUI.
JavaScript- conditions, Math objects. Generic Representation.
Quiz 3 Topics Functions – using and writing. Lists: –operators used with lists. –keywords used with lists. –BIF’s used with lists. –list methods. Loops.
JavaScript Tutorial. What is JavaScript JavaScript is the programming language of HTML and the Web Programming makes computers do what you want them to.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
 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.
ADMINISTRIVIA. LATES, REGRADES, …  Regrades: no more forms: need to see me in person in my office  Excused absences  If foreseeable, needs to be requested.
1-1 Logic and Syntax A computer program is a solution to a problem.
Variables and Data Types
JavaScript functions.
Programming the Web using XHTML and JavaScript
JavaScript: Functions
JavaScript Functions.
JavaScript Forms Adding User Input.
Introduction to Objects
Console.
Javascript: variables and parameters
JavaScript Functions.
In Class Program: Today in History
Reviewing key concepts
Variables and Data Types
Elements of a Python Program
Writing to a PAGE.
Workshop for Programming And Systems Management Teachers
JavaScript functions.
Writing to the Page Formatting Forms
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Introduction to Objects
Presentation transcript:

JavaScript Functions

CSS Inheritance

Which formatting applies? x y z input { display: block; } input.pref { background:red; } If you have a selector with no class, it applies to all of those elements REGARDLESS of class

Assignment Statements

Holding information  A computer doesn’t understand values  It takes locations and does what you tell it  It knows about “cubby holes”  A JavaScript Statement  Takes information from a cubby hole  Does what you say  And then puts it where you say

example A = B + C; Cubby Hole 2: add this value Cubby Hole 1: take this value Cubby Hole 3: place it here

CUBBY HOLES  3 types of cubby holes  Fields in a form  Function input and output  Specially defined ones  Differences  Some you can only read  Some you can only write  Some you can do both

Using Functions

What is a function?  Collection of statements that can be invoked as a unit  Can take parameters  Can return values  Can be used multiple times  Can call without knowing how they work

Parameters  Call a function with a different value every time  MUST give it everything that it expects  Some functions don’t require parameters  For alert  One parameter, the string to print

Inputs Output Black Box

Parameters Return Function Cubby holes I can just read Cubby hole I can just write

Format of a Function  Function_name(parm,parm);  Always needs () even if no parameter  Function_name();

The rules  The order of the parameters matter  different than 3 -5  Any number of parameters can be defined  Fixed for any specific function  Only a single output  Optional in general  Same for any specific function

Invoking a Function  Can be a statement by itself  alert(‘print’);  Or it can return a value and be part of an expression  sample.here.value=Date();  (more about Date later)

Forms and Functions

Form fields are cubby holes  Two cubby holes that we have learned about:  value: something that can be changed  src: the picture file

More about Date()  Returns an “object”  Collection of information  Year, month, day, house, minutes, seconds, milliseconds  Will cover way to get the pieces next week

Another useful function  Math.random()  Returns a value between 0 and 1  One of a series of mathematical functions  members of a collection called Math  each are prefixed by “Math.”

Using Functions  As a parameter  alert(Date());  As part of an expression  10*Math.random();