Javascript: variables and parameters

Slides:



Advertisements
Similar presentations
Javascript It’s not JAVA. What do these all have in common?
Advertisements

The Web Warrior Guide to Web Design Technologies
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 TIPS. REMEMBER JAVASCRIPT IS VERY, VERY CASE SENSITIVE.
1 Shortcuts for Lazy Programmers! Topics Increment and Decrement Operators Assignment Operators.
. If the PHP server is an server or is aware of which server is the server, then one can write code that s information. –For example,
JavaScript Programming Basics Chapter What is Programming?
JAVASCRIPT HOW TO PROGRAM -2 DR. JOHN P. ABRAHAM UTPA.
Introduction to JavaScript. JavaScript Facts A scripting language - not compiled but interpreted line by line at run-time. Platform independent. It is.
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
CISC474 - JavaScript 03/02/2011. Some Background… Great JavaScript Guides: –
Dynamic Web Pages & JavaScript. Dynamic Web Pages Dynamic = Change Dynamic Web Pages are web pages that change. More than just moving graphics around.
1 Functions Lecfture Abstraction abstraction is the process of ignoring minutiae and focusing on the big picture in modern life, we are constantly.
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
David Stotts Computer Science Department UNC Chapel Hill.
Introduction to Programming JScript Six Scripting functions Discuss functions Password Example.
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.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
COP 3813 Intro to Internet Computing Prof. Roy Levow Lecture 4 JavaScript.
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:
Functions Function is a standalone block of statements that performs some tasks and returns a value. Functions must be declared before they can be used.
JavaScript Functions. CSS Inheritance Which formatting applies? x y z input { display: block; } input.pref { background:red; } If you have a selector.
JavaScript Arrays, Functions, and Forms George Mason University.
Radio Buttons. Input/Form/Radio Group Use the dialog to enter label and values for the radio buttons.
Tutorial 11 1 JavaScript Operators and Expressions.
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 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.
A little PHP. Enter the simple HTML code seen below.
 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.
Build in Objects In JavaScript, almost "everything" is an object.
Web Systems & Technologies
Pertemuan 7 JavaScript.
>> JavaScript: Location, Functions and Objects
Learning to Program D is for Digital.
HTML & teh internets.
JavaScript - Errors & Exceptions Handling
A little MORE on JavaScript
JavaScript.
Variables and Data Types
EXCEPTION HANDLING IN SERVER CLIENT PROGRAMMING
JavaScript functions.
JavaScript (JS) Basics
JAVA Script : Functions Ashima Wadhwa
Barb Ericson Georgia Institute of Technology May 2006
Functions Comp 205 Fall ‘17.
JavaScript Functions.
JavaScript.
Console.
يمكن استدعاء الكود الوظيفي عند حدث معين أو عند استدعاء الكود الوظيفي .
Event Driven Programming & User Defined Functions
JavaScript Functions.
Functions, Part 2 of 2 Topics Functions That Return a Value
يمكن استدعاء الكود الوظيفي عند حدث معين أو عند استدعاء الكود الوظيفي .
Reviewing key concepts
Variables and Data Types
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.
Recognizing JavaScript Features
JavaScript Basics Topics Review Important Methods Writing Functions
Java Script Siddharth Srivastava.
JavaScript functions.
Brent M. Dingle Texas A&M University Chapter 5 – Section 2-3
JAVASCRIPT HOW TO PROGRAM -2
Programming Basics Review
3rd Party Widgets & Custom Code
Presentation transcript:

Javascript: variables and parameters 20 March 2014

What we want to do

Form with input, button, output HTML JavaScript

Add data HTML JavaScript

Push button and input data sent to javascript HTML JavaScript

Javascript uses the data to create a new result HTML JavaScript

And moves it to the output location HTML JavaScript

How do we do it?

variables A place to hold a value Mailbox: know where to pick up my mail; don’t know what’s in it How to define? var name; var name = initial-value;

Assignment statements target = new-value; CHANGE the value of the target variable TO the new-value new-value can be a constant, a variable, or an expression x = 3; x = y; x = x+ 5;

Using values from forms Value in the form can be treated just like a variable! Giving it a value User input Assign it a value in an onclick Define it in the HTML

FUNCTION: collection of instructions HTML JAVASCRIPT (function.js) <head> <script src=“function.js”></script> </head> <body> <button type=“button” onclick=“doit();”> </body> function doit () { alert(“Hi!”); }

parameters 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

FUNCTION with parameters HTML JAVASCRIPT (function.js) <head> <script src=“function.js”></script> </head> <body> <button type=“button” onclick=“doit(3,5);”> </body> function doit (a,b) { var c = a*b); alert(“product is ”+c); }

Return value 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

FUNCTION with return HTML JAVASCRIPT (function.js) <head> <script src=“function.js”></script> </head> <body> <button type=“button” onclick=“alert(doit(3,5));”> </body> function doit (a,b) { var c = a*b); return(c); }