c122mar413.notebook March 06, 2013

Similar documents
introjs.notebook March 02, 2014

COMS 469: Interactive Media II

CSC Web Programming. Introduction to JavaScript

Notesc120Mar515.notebook. March 05, Next I want to change the logic to handle all four of these:

Exercise 1: Basic HTML and JavaScript

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

JavaScript CS 4640 Programming Languages for Web Applications

Controlled Assessment Task. Question 1 - Describe how this HTML code produces the form displayed in the browser.

Client Side JavaScript and AJAX

Lab 3 - Pizza. Purpose. Assignment

JavaScript Basics. The Big Picture

Java Programming Fundamentals - Day Instructor: Jason Yoon Website:

Working with JavaScript

Command-driven, event-driven, and web-based software

Chapter 17. Fundamental Concepts Expressed in JavaScript

Programming language components

CMPT 100 : INTRODUCTION TO

ORB Education Quality Teaching Resources

Program Design Phase. Algorithm Design - Mathematical. Algorithm Design - Sequence. Verify Algorithm Y = MX + B

Title: Jan 29 11:03 AM (1 of 23) Note that I have now added color and some alignment to the middle and to the right on this example.

(Refer Slide Time: 01:40)

Discrete Structures Lecture 14

Lesson 6: Introduction to Functions

Enhancing Web Pages with JavaScript

COMP519 Practical 5 JavaScript (1)

JavaScript Introduction

1. Consider the following code snippet. Describe what the user will see when it is executed.

Lab 2 Population. Purpose. Assignment Lab 2 analyzes population growth of a town as well as compare the population growth of two towns.

Session 3: JavaScript - Structured Programming

Lab 1 Concert Ticket Calculator

JAVASCRIPT BASICS. Type-Conversion in JavaScript. Type conversion or typecasting is one of the very important concept in

Client-Side Web Technologies. JavaScript Part I

PES DEGREE COLLEGE BANGALORE SOUTH CAMPUS 1 K.M. before Electronic City, Bangalore WEB PROGRAMMING Solution Set II

Brief Intro to Firebug Sukwon Oh CSC309, Summer 2015

Lab 1. Purpose. Assignment. Action Items/Programming Requirements

JavaScript CS 4640 Programming Languages for Web Applications

Chapter 1: A First Program Using C#

3 The Building Blocks: Data Types, Literals, and Variables

Lesson 7: If Statement and Comparison Operators

(Refer Slide Time: 01:12)

Lesson 1: Writing Your First JavaScript

HTML5 and CSS3 More JavaScript Page 1

CGS 3066: Spring 2015 JavaScript Reference

JavaScript code is inserted between tags, just like normal HTML tags:

Midterms Save the Dates!

Enterprise Content Management System Monitor 5.2

CS 106 Introduction to Computer Science I

A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN

INTRODUCTION TO JAVASCRIPT

c122jan2714.notebook January 27, 2014

JavaScript Functions, Objects and Array

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

What is Java Script? Writing to The HTML Document. What Can JavaScript do? CMPT 165: Java Script

This tutorial will teach you about operators. Operators are symbols that are used to represent an actions used in programming.

Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object

"a computer programming language commonly used to create interactive effects within web browsers." If actors and lines are the content/html......


Midterm Exam. 5. What is the character - (minus) used for in JavaScript? Give as many answers as you can.

JQuery and Javascript

CS1046 Lab 4. Timing: This lab should take you 85 to 130 minutes. Objectives: By the end of this lab you should be able to:

COSC 122 Computer Fluency. Programming Basics. Dr. Ramon Lawrence University of British Columbia Okanagan

Key Concept: all programs can be broken down to a combination of one of the six instructions Assignment Statements can create variables to represent

ITEC136 - Lab 2 Population

Unit Notes. ICAWEB411A Produce basic client-side script for dynamic web pages Topic 1 Introduction to JavaScript

Software. Programming Languages. Types of Software. Types of Languages. Types of Programming. Software does something

People = End Users & Programmers. The Web Browser Application. Program Design Phase. Algorithm Design -Mathematical Y = MX + B

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

CS 106 Introduction to Computer Science I

Quiz 1: Functions and Procedures

Mobile App:IT. Methods & Classes

8. Control statements

NOTE: There are an awful lot of synonyms for "function" "routine, map [ ], procedure, [ ], subroutine, [ ], subprogram, [ ], function"

Get JAVA. I will just tell you what I did (on January 10, 2017). I went to:

Module 6. Campaign Layering

Place User-Defined Functions in the HEAD Section

QUIZ: What value is stored in a after this

Princess Nourah bint Abdulrahman University. Computer Sciences Department

Dynamism and Detection

Chapter 2 Working with Data Types and Operators

CSE 115. Introduction to Computer Science I

Programing for Digital Media EE1707. Lecture 3 JavaScript By: A. Mousavi and P. Broomhead SERG, School of Engineering Design, Brunel University, UK

JavaScript: The Basics

Initial Coding Guidelines

Manju Muralidharan Priya. CS4PM Web Aesthetics and Development WEEK 11

SEEM4570 System Design and Implementation Lecture 03 JavaScript

There are many other applications like constructing the expression tree from the postorder expression. I leave you with an idea as how to do it.

Decisions, Decisions. Testing, testing C H A P T E R 7

CS 106 Introduction to Computer Science I

Elementary Computing CSC 100. M. Cheng, Computer Science

Let's Look Back. We talked about how to create a form in HTML. Forms are one way to interact with users

PHP 1. Introduction Temasek Polytechnic

JAVASCRIPT - CREATING A TOC

CHAPTER 6 JAVASCRIPT PART 1

Chapter 1 - What s in a program?

CMPT 100 : INTRODUCTION TO

Privacy and Security in Online Social Networks Department of Computer Science and Engineering Indian Institute of Technology, Madras

Overview: Programming Concepts. Programming Concepts. Names, Values, And Variables

Overview: Programming Concepts. Programming Concepts. Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript

Chapter 3 - Simple JavaScript - Programming Basics. Lesson 1 - JavaScript: What is it and what does it look like?

DECISION STRUCTURES: USING IF STATEMENTS IN JAVA

Transcription:

These are the programs I am going to cover today. 1

2

Javascript is embedded in HTML. The document.write() will write the literal Hello World! to the web page document. Then the alert() puts out a pop up that says Hello World (shown on previous slide). 3

4

Now I am going to add a h1 header to the <html> just before the script Look at the next slide to see the results. 5

6

Note it should be charset I have an extra a in this and most of my examples thanks to copy and paste. I have fixed them online now. Now I am going to look at a web page set up with the usual HTML and including an h1 in HTML and h1 in Javascript. 7

8

the 0 is in the box when the prompt is displayed 9

10

11

When writing your HTML page, you follow the same rules that you did before you ae simply inserting Javascript. 12

13

14

15

16

Note that I can tell there is an error because the Javascript is showing up rather than being implemented. This had to be debugged. 17

Somehow I really messed up with copy and paste as you can see. 18

Finally I got the code straightened out! 19

20

I entered 0s quickly to see if it was cleaned up probably should have entered real numbers to see the multiply 21

22

I entered 5 and then 7 on the second prompt. Note that a + can mean concatenate and add. I do not specify datatype in Javascript so it has to figure out which to do. Calculating ans used concatenating and I see 57. If I do a convert on the number then Javascript determines I want to add. I see otherans after the add showing 12. 23

Someone asked if this would work it DID NOT. 24

But it did give me a way to show you how to find errors. In Firefox, go to Tools and then Web Developer and Error Console. 25

It pointed out the problem. 26

Ways to impact the data to cause the add to happen. parsefloat parseint + Number 27

28

I entered 5.55 and 4.44. 29

First I got prompted for two numbers and then I had to choose multiplication or division. 30

Here I am making a decision. My condition is to check and see if whattodo == "*" Note that when comparing for equality we use ==. What to do if whattodo does equal * is enclosed in the first set of curly braces. Otherwise I will take the else and what to do it it is false is enclosed in another set of curly braces. Note that the = here means assign. I do the calculation and assign it to ans. Note also that anything other than an * executes the else which means if I enter / it will do the else and if I enter Z it will do the else. 31

I could have said var whattodo = ""; 32

33

I entered 5 and then 6 and then / or something other than * and this was the result. 34

35

As shown in the previous slide, I entered + which is not an * and not a / so it is Problem. 36

37

38

Now I want to check for *, /, + or. 39

40

41

42

Can do with separate if statements but then the last one gets complex when you need to check for not any of the acceptable entries and you also have every decision checked every time. Not my favorite approach! 43

44

45

46

47

48

49

If the actions here are the same, you can use a compound otherwise simple if statements. 50

Compound since I do not care which is not true, I want to say not eligible. 51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66