Input & Output Functions JavaScript is special from other languages because it can accept input and produce output on the basis of that input in the same.

Slides:



Advertisements
Similar presentations
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
Advertisements

 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
Page 1 of 26 Javascript/Jscript Ch 7,8,9,10 Vadim Parizher Computer Science Department California State University, Northridge Spring 2003 Slides from.
Java review and more. Class Header  Public class Welcome  Case sensitive  Body of the class must be enclosed by braces.
Computer Science 103 Chapter 3 Introduction to JavaScript.
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
Introduction to Web Site Development Steven Emory Department of Computer Science California State University, Los Angeles Lecture 8: JavaScript I.
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 with Input & Output Step 1: Use tags JavaScript Template.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Introduction to scripting
آموزش طراحی وب سایت جلسه دهم – جاوا اسکریپت 1 تدریس طراحی وب برای اطلاعات بیشتر تماس بگیرید تاو شماره تماس: پست الکترونیک :
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
Introduction to JavaScript. JavaScript Facts A scripting language - not compiled but interpreted line by line at run-time. Platform independent. It is.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT
1 Week Three: Using Scripts and Forms in HTML (Week Three) By Dr Fadi Safieddine.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
JavaScript Part 1.
Using JavaScript in FORMs Fort Collins, CO Copyright © XTR Systems, LLC Learning to Use JavaScript in HTML FORMs Instructor: Joseph DiVerdi, Ph.D., MBA.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 10 - JavaScript: Functions Outline 10.1 Introduction 10.2 Program Modules in JavaScript 10.3.
Objective Static vs. Dynamic Web pages. Variables. Assignments. JavaScript Hierarchy of Objects JavaScript Functions (prompt(“”,””) Document.write(“”)
Using Client-Side Scripts to Enhance Web Applications 1.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Dynamic Web Pages & JavaScript. Dynamic Web Pages Dynamic = Change Dynamic Web Pages are web pages that change. More than just moving graphics around.
JavaScript - A Web Script Language Fred Durao
Copyright ©2005  Department of Computer & Information Science Introducing Dialogue Windows.
Variety of JavaScript Examples Please use speaker notes for additional information!
1 JavaScript
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
Introduction to Programming JScript Six Scripting functions Discuss functions Password Example.
JavaScript Making Web pages come alive. Objectives Be able to read JavaScript scripts Be able to write JavaScript scripts.
Event JavaScript's interaction with HTML is handled through events that occur when the user or browser manipulates a page. When the page loads, that is.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
JavaScript, Fourth Edition
Conditional Statements © Copyright 2014, Fred McClurg All Rights Reserved.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
Making dynamic pages with javascript Lecture 1. Java script java versus javascript Javascript is a scripting language that will allow you to add real.
JavaScript Challenges Answers for challenges
JavaScript 1 COE 201- Computer Proficiency. Introduction JavaScript scripting language ▫Originally created by Netscape ▫Facilitates disciplined approach.
Chapter 12: Objects CIS 275—Web Application Development for Business I.
Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing a Line of Text in a Web Page 7.3 Another JavaScript.
Adapted from  2004 Prentice Hall, Inc. All rights reserved. 5 th and 4 th ed: Chapters 6,7,8 SY306 Web and Databases for Cyber Operations SlideSet #6:
Chapter 5: Intro to Scripting CIS 275—Web Application Development for Business I.
Working with the Window Object JavaScript considers the browser window an object, which it calls the window object.
Chapter 4 Java Script - Part1. 2 Outlines Introduction to Java Script Variables, Operators and Functions Conditional statements JavaScript Objects Forms.
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.
1 /25 Working with Return Templates with TaxWise Online © 2006, Universal Tax Systems, Inc. All Rights Reserved. TaxWise Online Return Templates Objectives.
1 Lesson 6 Introducing JavaScript HTML and JavaScript BASICS, 4 th Edition.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Popup Boxes.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
INTERNET APPLICATIONS CPIT405 JavaScript Instructor: Rasha AlOmari
WEB SYSTEMS & TECHNOLOGY. Java Script  JavaScript created by Netscape  It is also client side programming  It can be use for client side checks.
JavaScript, Third Edition 1 SELECTION LIST Demo. JavaScript, Third Edition 2 Description This web page will edit the slection to ensure an option was.
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
© 2010 Robert K. Moniot1 Chapter 6 Introduction to JavaScript.
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
Chapter 13 - JavaScript/JScript: Introduction to Scripting
WEB APPLICATION PROGRAMMING
CHAPTER 4 CLIENT SIDE SCRIPTING PART 2 OF 3
Message, Input, Confirm, and Specialized Dialogs
Predefined Dialog Boxes
WEB PROGRAMMING JavaScript.
برمجة صفحات إنترنت (JavaScript )
We are starting JavaScript. Here are a set of examples
Chapter 7 - JavaScript: Introduction to Scripting
CS105 Introduction to Computer Concepts JavaScript
Presentation transcript:

Input & Output Functions JavaScript is special from other languages because it can accept input and produce output on the basis of that input in the same page. That mean, you don't have to go to other page or refresh the page to see the output.

Functions to show output 1) window.alert() 2) window.status() 3) document.write() 4) document.writeln()

Details of the Output Functions 1) window.alert() This function show the message in a small messagebox. The messagebox contains the string and an “OK” button on it. If the user presses the "OK" button the messagebox disappears. The message to be displayed has to be passed as parameter window.alert().

Code example window.alert ("Hello"); The above code displays a message box with the string "Hello" on it.

Output Functions 2) window.status() This function show the message in status- bar. The message to be displayed has to be passed as parameter window.status().

Code example window.status ="Welcome to JavaScript"; The above code displays a message "Welcome to JavaScript" in the status bar.

Output Functions 3) document.write() This function print a string in the current page. The message to be displayed has to be passed as parameter document.write(). 4) document.writeln() This function works as the same way as document.write().

Code example document.write( "Welcome to JavaScript"); document.close(); The above code displays a message "Welcome to JavaScript" on the page.

Code example You can also add HTML tags with document.write() document.writeln( " "); document.writeln( "Welcome to JavaScript"); document.write( " "); Here you can see HTML tag is added so the string "Welcome to JavaScript" is printed in bold format.

Functions: taking Input from User 1) window.prompt() 2) window.confirm()

Details of the Input Functions 1) window.prompt() This function is used to get any value from the user. This function takes two optional parameters. Returns the value entered by the user in String format, however if user press "cancel" returns "Null”. String window.prompt("Question", "default answer")

Code example var s; s = window.prompt("What is your name ?", "your name here" ); document.writeln( s); The above program asks user his name, and when the user enters his name and press "OK", the name of user is printed.

Code example var no1,no2, ans; no1 = window.prompt("Give the first number ?", "0" ); // get the first input no2 = window.prompt("Give the second number ?", "0" ); // get the first input ans = parseFloat (no1) + parseFloat (no2); //convert to float and add them document.writeln( ans); // print the answer

Input Functions 2) window.confirm() This function prompts the user to confirm the decision. It shows a messageBox with two buttons "OK" and "CANCEL" on it. If user press "OK" it returns "true", if user press "CANCEL" it returns false.

Code example var no1,no2, ans; ans = window.confirm("Are you ready?") if (ans==true) // check users response document.writeln( "Start learning JavaScript"); else document.writeln( "Try later");