Introduction to JavaScript CS101 Introduction to Computing.

Slides:



Advertisements
Similar presentations
3.02D HTML Overview 3.02 Develop webpages.
Advertisements

Introducing JavaScript
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Introduction to JavaScript
The Web Warrior Guide to Web Design Technologies
2440: 211 Interactive Web Programming JavaScript Fundamentals.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Introduction to Scripting.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
Creating Web Page Forms
1 CS101 Introduction to Computing Lecture 12 Interactive Forms (Web Development Lecture 4)
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Introduction to scripting
8/17/2015CS346 PHP1 Module 1 Introduction to PHP.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
4.1 JavaScript Introduction
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
1 CS101 Introduction to Computing Lecture 18 Objects, Properties, Methods (Web Development Lecture 6)
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
1 VU. 2 CS101 Introduction to Computing Lecture 15 More on Interactive Forms (Web Development Lecture 5)
Introduction to JavaScript + More on Interactive Forms.
1 CS428 Web Engineering Lecture 11 Client Side Scripting (JavaScript - I)
CSS Class 7 Add JavaScript to your page Add event handlers Validate a form Open a new window Hide and show elements Swap images Debug JavaScript.
10/5/2015CS346 PHP1 Module 1 Introduction to PHP.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and check boxes using HTML Add a pull-down.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Tutorial 10 Programming with JavaScript
Tutorial 8 Programming with ActionScript 3.0. XP Objectives Review the basics of ActionScript programming Compare ActionScript 2.0 and ActionScript 3.0.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
JavaScript. During the last lecture We looked at the utility of forms on Web pages We found out about the various components that are used in a form We.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
JavaScript Syntax, how to use it in a HTML document
Introduction to JavaScript Objects, Properties, Methods.
Introduction into JavaScript Java 1 JavaScript JavaScript programs run from within an HTML document The statements that make up a program in an HTML.
1 JavaScript in Context. Server-Side Programming.
Scripting Languages Client Side and Server Side. Examples of client side/server side Examples of client-side side include: JavaScript Jquery (uses a JavaScript.
HTML Overview Part 5 – JavaScript 1. Scripts 2  Scripts are used to add dynamic content to a web page.  Scripts consist of a list of commands that execute.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Chapter 1 Introduction to JavaScript JavaScript, Third Edition.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
HTML Tutorial. What is HTML HTML is a markup language for describing web documents (web pages) HTML documents are described by HTML tags Each HTML tag.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Donna J. Kain, Clarkson University
Section 17.1 Section 17.2 Add an audio file using HTML
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Tutorial 10: Programming with javascript
An Introduction to JavaScript
Introduction to Programming and JavaScript
Introduction to JavaScript
Presentation transcript:

Introduction to JavaScript CS101 Introduction to Computing

Let’s now review what happens when I enter all the required info and press the “Send ” button?

Info contained in the form Acknowledgement Message to the receiver’s address User’s Computer Web Server Server-Side Script Browser

This is what happens when the form is filled correctly. What if the form is filled incorrectly? What if the users leaves one of the essential fields, blank? What if the user enters an illegal address? Examples: –ihussain2imt.edu.p

A Reasonable Scenario When the “Send ” button is clicked, the browser sends the data collected through the form to a script running on the Web server That server-side script: –receives that data –analyzes it –discovers the missing or incorrect data –sends a message back to the user’s browser stating the problem and asks the user to re-send

This process … That is the process of the user: –Filling the incomplete/incorrect data –Sending it to the server –Receiving the response back from the server –Correcting and resending is quite time-consuming and uses the server’s resources to help the user correct his mistakes It can really bog down the server if a large number of users are using that Web server

Client-Side Scripting is a viable alternate In this technique, one uses the user’s browser to checking the form data If data is missing or is incorrect, the browser can prompt the user to take corrective action This way, the form data is sent to the server-side script only after it has been established that the collected data is complete and correct

Server-Side Scripts: Review Are programs that reside on Web servers Receive info that a user enters in a form Process that info and take appropriate action Examples: –CGI scripts on Unix servers –ASP scripts on Windows servers

Elements of the form name: Name given to the form method: Forms can be submitted through two alternate methods – GET & POST action: Specifies the URL that is accessed when the form is being submitted

New Concept: Client-Side Scripts Small programs that are a part of the Web page and run on the user’s (client’s) computer They interact with the user to collect info or to accomplish other tasks Once it has been collected, they may help pass the collected info on to a server-side script We’ll use JavaScript to do client-side scripting. However, there are many other languages that can be used for that purpose, e.g. VBScript

Advantages of Client-Side Scripting Reduced server load as it does not have to send messages to the user’s browser about missing or incorrect data Reduced network traffic as the form’s data is sent only once instead of many to’s and fro’s

Disadvantages Client-side scripts do not work with all browsers Some user intentionally turn scripting off on their browsers This increases the complexity of the Web page, as it now has to support both situations: browsers with scripting capability, and those not having that capability

A Simple Example of Client- Side Scripting

Why JavaScript? HTML is great for static Web pages; however, supports only rudimentary interactivity through forms and hyperlinks JavaScript can be used (along with HTML) to develop more interactive content for the Web

What is JavaScript? A programming language specifically designed to work with Web browsers It is designed to be used for developing small programs – called scripts – that can be embedded in HTML Web pages JavaScript: –Is an interpreted language –Supports event-driven programming –Is object-based

Object Based? Everything that JavaScript manipulates, it treats as an object – e.g. a window or a button An object has properties – e.g. a window has size, position, status, etc. Properties are modified with methods – e.g. a resize a window with resizeTo(150, 200)

Object-Based JavaScript uses items called ‘objects’ Objects are not ‘class-based’ –No distinction made between class and instance

Scripting Languages Code is interpreted as it is loaded in client

What You Need to Know HTML Text editors Web browsers Different versions of JavaScript

How to Use JavaScript? JavaScript placed within HTML code Use the HTML SCRIPT tag JavaScript can be placed in either the ‘Head’ or ‘Body’ portion of an HTML document

SCRIPT Tag Comes in in pairs Opening SCRIPT tag Closing SCRIPT tag Tells browser where script begins and ends Identifies scripting language and version Specifies address for an external JavaScript file

Case Sensitivity SCRIPT tag is NOT case sensitive JavaScript inside SCRIPT tag IS case sensitive

See Example 1 … Write a string of text to a Web page

JavaScript Rules Parentheses –Required by JavaScript functions –The document.write method is a function that takes an argument contained in parentheses Quotation Marks –Denote a string of text in JavaScript (a string is a type of variable) Semicolon –Signals end of JavaScript statement (a statement is a portion of code that does not need anything added to it to be complete in its syntax) Syntax –Form and order of programming code

Calling External Scripts External JavaScript file –Text file that contains JavaScript code –Saved with ‘.js’ extension –Saves time coding a script into each page

See Example 2 …

Hiding JavaScript from Older Browsers Older browsers may not recognize JavaScript –May dump entire JavaScript code as text on screen Tell older browsers to ignore JavaScript –Use HTML comments between ‘SCRIPT’ tags (<!--)Opening HTML comment code (//-->)Closing HTML comment code

See Example 3 …

JavaScript Comments Benefits –To add notes –To look for error in script Single-line comments // Your comments go here Multi-line comments (/*)Opening code (*/) Closing code

See Example 4 …