Conditional Statements.  Checking if input is a number  Radio buttons  Check boxes 2.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

CS0004: Introduction to Programming Select Case Statements and Selection Input.
1 COMM 1213 H1 COMP 4923 X1 JavaScript 1 (Readings: Ch. 10, 11 Knuckles)
8 November Forms and JavaScript. Types of Inputs Radio Buttons (select one of a list) Checkbox (select as many as wanted) Text inputs (user types text)
Lecture 2: Topics Bits and Bytes Primitive Types Casting Strings Boolean expressions.
EXAMPLE 1 Multiplying Decimals by Whole Numbers Find the product
Presents. What are integers? positive numbersnegative numbers Integers is the family name for positive and negative whole numbers.
CST JavaScript Validating Form Data with JavaScript.
Game Programming © Wiley Publishing All Rights Reserved. The L Line The Express Line to Learning L Line L.
JavaScript: Control Structures September 27, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel,
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
 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.
Week 2 - Monday.  What did we talk about last time?  Software development  Lab 1.
JavaScript Lecture 6 Rachel A Ober
Javascript. Javascript Tools Javascript Console Javascript Console Debugger Debugger DOM Inspector DOM Inspector.
CHAPTER 4 Java Script อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
Lecture 2: Classes and Objects, using Scanner and String.
Using Client-Side Scripts to Enhance Web Applications 1.
1 Forms and Form elements CSD 340 McCoey. 2 Form Object Properties action Usually a call to a server elements encoding method post or get target Methods.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Chapter 5: Data Types (2013) Revision Candidates should be able to know: Identify different data types? Key terms: File, record, field and key field Database.
3 - Variables Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Algebra and Trigonometry III by: Mr Pol Ogrimen Jr.
Flow of Control Part 1: Selection
ITM © Port, KazmanVariables - 1 ITM 352 Data types, Variables.
Decisions  Relational operators  Operate on two numbers or two Strings  ==, !=, >, >=,
Xin Liu Feb 4, * Use midterm questions for previous 231/217 midterms for practices * ams
Sets of real Numbers.
Murach’s C# 2010, C5 © 2010, Mike Murach & Associates, Inc.Slide 1.
Variables and Data Types Data (information we're going to store) – Numbers – Text – Dates What types of data can JavaScript process? How do we store it?
CS 101 Test 2 Study Guide Acronyms RAD - Rapid Application Development IDE - Integrated Development Environment GUI - Graphical User Interface VB - Visual.
Decision Structures, String Comparison, Nested Structures
Chapter 2 Input, Variables and Data Types. JAVA Input JAVA input is not straightforward and is different depending on the JAVA environment that you are.
Pay Example (PFirst98) Please use speaker notes for additional information!
Java Script About Java Script Document Object Model Incorporating JavaScript Adding JavaScript to HTML Embedding a Javascript External Scripts Javascript.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Variables.
Unit 2 — The Exciting World of JavaScript Lesson 7 — Creating Forms with JavaScript.
Chapter One Lesson Three DATA TYPES ©
EGR 115 Introduction to Computing for Engineers Branching & Program Design – Part 3 Friday 03 Oct 2014 EGR 115 Introduction to Computing for Engineers.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
GCSE Computing: Programming GCSE Programming Remembering Python.
5-3(D) Real Numbers.
Logical Operators.  Quiz  Let's look at the schedule  Logical Operators 2.
Checking If User Input Is Numeric.  Quiz  Detecting numeric input  Finish Prior Lecture  Y'all work on one of the problems listed 2.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand how decisions are made in a computer ❏ To understand the logical.
Logical Operators.  Quizzes!  Let's look at the schedule  Logical Operators 2.
7 - Programming 7J, K, L, M, N, O – Handling Data.
DATA TYPES.
CSS Colors, JavaScript Variables, Conditionals and Basic Methods
A variable is a name for a value stored in memory.
BIT116: Scripting Lecture 06
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
Javascript Conditionals.
Engineering Innovation Center
Chapter 2.
Chapter 7 - JavaScript: Introduction to Scripting
Console.
JavaScript: Introduction to Scripting
Introduction to Primitive Data types
Due Next Monday Assignment 1 Start early
Variables Kevin Harville.
Chapter 7 - JavaScript: Introduction to Scripting
C# Revision Cards Data types
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Data Types and Maths Programming Guides.
Boolean in C++ CSCE 121.
Introduction to Primitive Data types
Sets and Subsets Cornell Notes
Presentation transcript:

Conditional Statements

 Checking if input is a number  Radio buttons  Check boxes 2

3 Checking if a value is a number

 Examples of data types:  Integer - whole numbers only, but positive, negative, and zero are allowed  Floating-point / real - any number (whole or with a decimal point), positive, negative, zero  Strings – text ("a string of individual characters")  Boolean – true or false  JS will try to convert from one to another in order to help you out.  FILE: loosely_typed.html  Note: multiplying by two is great  Adding 4 isn't great  Sometimes we need to tell it what to do 4

 The isNaN() function will tell us if it's NOT a number  NaN = Not A Number  parseFloat() will then convert it to a real, floating-point number with decimals  Use parseInt() if you want to drop anything after the decimal point  Then it's safe to do math on it  FILE: checking_for_numbers.html  Step 1: Check if it's actually a number using isNaN (error & exit if it isn't)  Step 2: Convert it to a number using parseFloat/parseInt  Step 3: Do the math 5

 Do exercise #1 for this topic 6

7 HTML Radio buttons

 If  Form validation  If not a number, etc?  HTML  If…else  2-item radio buttons?  HTML  Multiway  An item in a list is best described as ____________  Day or week  Grade (small scale)  Default case is an error  N-way radio button  HTML  Drop-down list  HTML  Logical ops  Guessing game?  Figuring out tax in a variety of states, for a variety of items? 8

  Keep the console open  Assertions  Using alert  Using console.log  Printing out objects (including fields)   Using an actual debugger – debugger;  Console.log( " object: %o string: %s", obj, obj.property); 9