CONDITIONALS DATE CHANGES OUTSIDE FORMS. CONDITION ALS.

Slides:



Advertisements
Similar presentations
getElementById() document.getElementById(“idName").innerHTML = “Any valid content"; getElementById is a method innerHTML is a property.
Advertisements

Javascript Introduction Norman White Material is from w3schools.com Go there to run examples interactively.
The Document Object Model (DOM) 1 JavaScript is an object-based language—that is, it’s based on manipulating objects by changing each object’s properties.
JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
1 JavaScript: Control Structures II. 2 whileCounter.html 1 2
Page Elements © Copyright 2014, Fred McClurg All Rights Reserved.
Making Decisions in Python Sec 9-10 Web Design. Objectives The student will: Understand how to make a decision in Python Understand the structure of an.
Selection (decision) control structure Learning objective
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Tutorial 11 Working with Operators and Expressions
JAVASCRIPT TIPS. REMEMBER JAVASCRIPT IS VERY, VERY CASE SENSITIVE.
Monday, Week 3 Conditional Statements! If-then statements If-then-else statements Nested if-statements Some examples… Mini-Lab 3!
Forms, Validation Week 7 INFM 603. Announcements Try placing today’s example in htdocs (XAMPP). This will allow you to execute examples that rely on PHP.
JavaScript onLoad getElement. onload Using JavaScript to create content No user input Comes up when page LOADS [redo Koozebane; random picture]
JavaScript Events and Event Handlers 1 An event is an action that occurs within a Web browser or Web document. An event handler is a statement that tells.
Department of Information Technology e-Michigan Web Development 0 HTML Form Creation in the Vignette Content Management Application.
Using Object-Oriented JavaScript CST 200- JavaScript 4 –
Chapter 5 Java Script And Forms JavaScript, Third Edition.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
JavaScript Lecture 6 Rachel A Ober
CISC474 - JavaScript 03/02/2011. Some Background… Great JavaScript Guides: –
Week 9 PHP Cookies and Session Introduction to JavaScript.
1 Introduction to Javascript Peter Atkinson. 2 Objectives To understand and use appropriately some of the basic elements of Javascript: –alert and prompt.
Review IDIA 619 Spring 2013 Bridget M. Blodgett. HTML A basic HTML document looks like this: Sample page Sample page This is a simple sample. HTML user.
Manipulating the DOM CST 200 – JavaScript 3 –
Using the selection structure (Unit 7) Visual Basic for Applications.
1 JavaScript 1. 2 Java vs. JavaScript Java –Is a high level programming language –Is platform independent –Runs on a standardized virtual machine.
JavaScript, Fourth Edition
CHAPTER 4 Java Script อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
PAGES:51-59 SECTION: CONTROL1 : DECISIONS Decisions.
Using Client-Side Scripts to Enhance Web Applications 1.
Arrays, date, random. Declared Variables Explicitly define them Can give them starting values Figures out type Case sensitive var x = 5; (note: this is.
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
The Web Wizard’s Guide To JavaScript Chapter 8 Working with Windows and Frames.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
COP 3813 Intro to Internet Computing Prof. Roy Levow Lecture 4 JavaScript.
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
Complex Conditionals. N-way decisions How to deal with more than 2 alternates? Nested else statements.
Midterm1 answers: Page 1 1 a6 b6 c0 2 ***. Midterm1 answers: Page 2 A)a. 53b. 44c. 13d. 75e. 77 B)a. 53b. 17c. 33 / 44d. 13e. 75 C)a. ‘5’b. ‘3’c. ‘ ‘d.
Tutorial 11 1 JavaScript Operators and Expressions.
XP Tutorial 3 New Perspectives on JavaScript, Comprehensive1 Working with Arrays, Loops, and Conditional Statements Creating a Monthly Calendar.
GetElementById changes outside forms. From form to page  Identified the field by using name  Form.field  Outside a form, use id  Unique on the page.
CSD 340 (Blum)1 Introducing Text Input elements and Ifs.
JavaScript, Sixth Edition
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
JAVASCRIPT A quick review. True False ■The DOM is a standardized way of referring to parts of a Web page. ■TRUE ■In the DOM, attributes have their own.
JavaScript Tutorial. What is JavaScript JavaScript is the programming language of HTML and the Web Programming makes computers do what you want them to.
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
JavaScript, Sixth Edition
Programming Web Pages with JavaScript
JavaScript Arrays Date
Introduction to Scripting
JavaScript Syntax and Semantics
Javascript Conditionals.
JavaScript conditional
In Class Programming BIS1523 – Lecture 11.
Document Object Model (DOM): Objects and Collections
Pages:51-59 Section: Control1 : decisions
JavaScript onLoad arrays
The Web Wizard’s Guide To JavaScript
JavaScript conditional
Program Flow.
JavaScript: Introduction to Scripting
Pages:51-59 Section: Control1 : decisions
Writing to the Page Formatting Forms
Web Programming and Design
Presentation transcript:

CONDITIONALS DATE CHANGES OUTSIDE FORMS

CONDITION ALS

IF … THEN … ELSE if (MUST BE LOWERCASE) No else: do nothing if not true else: one or the other else if: nested function

OPERATORS OperatorMeaning ==Is equal to !=Is not equal >Is greater than <Is less than >=Is greater than or equal to <=Is less than or equal to OperatorMeaning &&and ||or !not Logical Conditional

CONDITIONAL EXAMPLE Random message using if Simple if…then…else Condition is random function

N-WAY DECISIONS More than 2 alternates? Nested else statements (else if) switch – case (Excel CHOOSE) Example: Random message using switch

BUT IF IT’S ONLY THE DATA… Arrays Collection of items referenced with index Just keep adding items! Start with 0 Example: Select an element from an array

DATE

DATE AND TIME Full date is unfriendly format To get today’s date:var d = new Date(); To get the time:var time = d.getHours(); To get the day: var theDay=d.getDay(); w3schools

WHAT DOES IT MEAN? Objects have attributes Chair: color, size, legs, wheels, … Date: year, month, day, day of week, hour, … Object.retrieve-attribute Assign the date with built in function Date() Extract the piece using getHours, getDays, …

DATE AND TIME EXAMPLES 3 messages based on Hour Prints an appropriate message based on time of day (3 choices) 2 messages based on Day Prints an appropriate message based on day of week (2 choices)

CHANGES OUTSIDE FORMS

RETRIEVING THE VALUE In JavaScript document.getElementById("name").value What does that mean? document: the web page getElementById: find this id on the page Returns an object Value: get the value of the object

WRITING TO THE PAGE Use an id on any element Replace the element using innerHTML Allows us to keep the correct semantics in HTML Using innerHTML

CHANGING HTML General structure: context.element.attribute Within form: formname.element.attribute form-name.input-id.value form-name.img-id.src Outside form: document.getElementById(“id-name”).attribute document.getElementById(“id”).innerHTML document.getElementById(“id”).className document.getElementById(“id”).src