<HTML> <HEAD> <TITLE>Javascript Example</TITLE> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> <!-- alert("Thank you for visiting my web site!")

Slides:



Advertisements
Similar presentations
IM 215 Operators, Conditions and Loops. Review Nature of Javascript How to include Javascript on a page Declaring and assigning variables Commenting code.
Advertisements

14/11/11.  These words have special meanings in themselves  These should NOT be used as Identifiers.  For example:  Break, do, function, case, else,
16/19/2015CS120 The Information Era CS120 The Information Era Chapter 5 – Advanced HTML TOPICS: Introduction to Web Page Forms and Introductory Javascript.
Lesson 14.
IDK0040 Võrgurakendused I harjutus 07: PHP: Operators, Switch, Forms Deniss Kumlander.
SYST Web Technologies SYST Web Technologies Lesson 6 – Intro to JavaScript.
Week 9 PHP Cookies and Session Introduction to JavaScript.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
CS-3432 Electronic Commerce Lecture – 13 Sikandar Shujah Toor
Operators. Today’s Learning Goals … Understand the purpose of JavaScript operators Explore the mathematical operators Find out about the assignment operators.
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
Scott Marino MSMIS Summer Session Web Site Design and Authoring Session 8 Scott Marino.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
JavaScript, Fourth Edition
1 JavaScript Part 3. Functions Allow the user to decide when a particular script should be run by the browser in stead of running as long as the page.
CSCE 102 – Chapter 11 (Performing Calculations) CSCE General Applications Programming Benito Mendoza Benito Mendoza 1 By Benito Mendoza.
Javascript JavaScript is what is called a client-side scripting language:  a programming language that runs inside an Internet browser (a browser is also.
Izzy PHP and MySQL Session 1: What is PHP?
Introduction to Calculated Columns Variables, Conditionals, and String Manipulation PRESENTER: Cameron Blashka| Informer Implementation Specialist| April.
JavaScript.
>> Fundamental Concepts in PHP
Java Script Introduction. Java Script Introduction.
CHAPTER 4 DECISIONS & LOOPS
Introduction to Client-Side Scripting and JavaScript
CHAPTER 10 JAVA SCRIPT.
CHAPTER 4 CLIENT SIDE SCRIPTING PART 1 OF 3
>> JavaScript: Location, Functions and Objects
HTML & teh internets.
CHAPTER 4 CLIENT SIDE SCRIPTING PART 3 OF 3
JavaScript Wrap-up.
JavaScript is a programming language designed for Web pages.
JavaScript - Errors & Exceptions Handling
A little MORE on JavaScript
Operators Operators are symbols such as + (addition), - (subtraction), and * (multiplication). Operators do something with values. $foo = 25; $foo – 15;
EXCEPTION HANDLING IN SERVER CLIENT PROGRAMMING
JavaScript Loops.
Functions Comp 205 Fall ‘17.
Programming the Web using XHTML and JavaScript
WEB APPLICATION PROGRAMMING
Chapter 6: Conditional Statements and Loops
JavaScript.
BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES
CNIT 133 Interactive Web Pags – JavaScript and AJAX
Document Object Model
Exercises on JavaScript & Revision
Javascript الجافا سكربت هي لغة برمجه اذا جاز التعبیر تلعب دور حیوي وفعال في صفحات الویب من خلال القیام بوظائف قد تكون خارجیة او داخلیة بل لنكن اكثر دقة.
Introduction to JavaScript for Python Programmers
PHP: Basics FdSc Module 109 Server side scripting and Database design
The Web Wizard’s Guide To JavaScript
Web Programming Language
CS105 Introduction to Computer Concepts
Lect2 (MCS/BCS) Javascript.
Client-Server Model Client A Server X file Internet file Client B
HTML scripts.
BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES
JavaScript Part 2.
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT
Operations Python code.
Pertemuan 13 JavaScript.
Radoslaw Jedynak, PhD Poland, Technical University of Radom
JavaScript Basics What is JavaScript?
JavaScript is a scripting language designed for Web pages by Netscape.
The <script> Tag
Software Engineering for Internet Applications
Web Programming– UFCFB Lecture 13
Using C++ Arithmetic Operators and Control Structures
Web Programming and Design
This is an introduction to JavaScript using the examples found at the CIS17 website. In previous examples I specified language = Javascript, instead of.
CS105 Introduction to Computer Concepts JavaScript
Presentation transcript:

<HTML> <HEAD> <TITLE>Javascript Example</TITLE> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> <!-- alert("Thank you for visiting my web site!") //--> </SCRIPT> </HEAD> <BODY> </BODY> </HTML>

<HTML> <HEAD> <TITLE>example-writing on the page</TITLE> </HEAD> <BODY> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> <!-- document.write("Hello! Thank you for visiting my web site.") //--> </SCRIPT> </BODY> </HTML>

Functions Definition function myfunction() { // some code }

Operators in JavaScript + For addition of two values - for subtraction of two values * for multiplication / for division % modulus (calculating the remainder) ++ increment -- decrement

Logical operators && logical and || logical or ! logical not if(x<y&&x<z) { any statement } if(!false){ statement }

Comparison Operators == Equal != not equal < Less than <= less than equal > Greater than >= Greater than equal

<HTML> <script language="JavaScript"> <!-- function Addit() { var num1=document.Calform.One.value; var num2=document.Calform.Two.value; alert(parseFloat(num1)+parseFloat(num2)); } function minus() alert(parseFloat(num1)-parseFloat(num2)); //--> </script> <BODY>Add and Subtract Calculator <FORM name="Calform"> <P> First Number:<INPUT TYPE="TEXT" NAME="One" maxlength="3"> Second Number:<INPUT TYPE="TEXT" NAME="Two" maxlength="3"> <INPUT TYPE="button" NAME="Add" VALUE="Add Them!!" onclick="Addit()"> <INPUT TYPE="button" NAME="Minus" VALUE="Subtract Them!!" onclick="minus()"> <INPUT TYPE="RESET" VALUE="Reset!"> </FORM> </BODY> </HTML>

Calculator <HTML> <HEAD>Add Subtract Calculator <script language="JavaScript"> <!-- function Addit() { var num1=document.Calform.One.value; var num2=document.Calform.Two.value; document.Calform.result.value=parseFloat(num1)+parseFloat(num2); //alert(parseFloat(num1)+parseFloat(num2)); } function minus() document.Calform.result.value=parseFloat(num1)-parseFloat(num2); //alert(parseFloat(num1)-parseFloat(num2)); //--> </script>

Calculator <Title> My Simple Calculator</Title> <BODY> <FORM name="Calform"> <P> First Number:<INPUT TYPE="TEXT" NAME="One" maxlength="3"> Second Number:<INPUT TYPE="TEXT" NAME="Two" maxlength="3"> Result:<INPUT TYPE="TEXT" NAME="result" maxlength="9" Disabled> <INPUT TYPE="button" NAME="Add" VALUE="Add Them!!" onclick="Addit()"> <INPUT TYPE="button" NAME="Minus" VALUE="Subtract Them!!" onclick="minus()"> <INPUT TYPE="RESET" VALUE="Reset!"> </FORM> </BODY> </HTML>

<HTML> <script language="JavaScript"> <!-- function Addit() { var num1=document.Calform.One.value; var num2=document.Calform.Two.value; document.write("The result of this addition is " + (parseFloat(num1)+parseFloat(num2))); } function minus() document.write("The result of this subtraction is " + (parseFloat(num1)-parseFloat(num2))); //--> </script> <BODY> <FORM name="Calform"> <P> First Number:<INPUT TYPE="TEXT" NAME="One" maxlength="3"> Second Number:<INPUT TYPE="TEXT" NAME="Two" maxlength="3"> <INPUT TYPE="button" NAME="Add" VALUE="Add Them!!" onclick="Addit()"> <INPUT TYPE="button" NAME="Minus" VALUE="Subtract Them!!" onclick="minus()"> <INPUT TYPE="RESET" VALUE="Reset!"> </FORM> </BODY> </HTML>

<HTML> <script language="JavaScript"> <!-- function Multiplyit() { var num1=document.Calform.One.value; var num2=document.Calform.Two.value; alert(parseFloat(num1)*parseFloat(num2)); } function Divideit() alert(parseFloat(num1)/parseFloat(num2)); //--> </script> <BODY><h2> Multiply and Divide Calculator</h2> <FORM name="Calform"> <P> First Number:<INPUT TYPE="TEXT" NAME="One" maxlength="3"> Second Number:<INPUT TYPE="TEXT" NAME="Two" maxlength="3"> <INPUT TYPE="button" NAME="Multiply" VALUE="Multiply" onclick="Multiplyit()"> <INPUT TYPE="button" NAME="Divide" VALUE="Divide" onclick="Divideit()"> <INPUT TYPE="RESET" VALUE="Reset!"> </FORM> </BODY> </HTML>

<HTML> <HEAD> <TITLE>A Drop-Down List of Links</TITLE> </HEAD> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> <!-- function GoToIt(list) { var selection = list.options[list.selectedIndex].value if (selection != "None") location.href = selection } //--> </SCRIPT> <BODY> <FORM> <SELECT WIDTH="20" onChange="GoToIt(this)"> <OPTION VALUE="None">Select a page previously done ---> <OPTION VALUE="calculator.htm">Calculator <OPTION VALUE="styles.htm">Style Sheet <OPTION VALUE="forms.htm">Web Forms <OPTION VALUE="tablemargin.htm">Table Margins <OPTION VALUE="frames.htm">Frames </SELECT> </FORM> </BODY> </HTML>

<HTML> <script language="JavaScript"> <!-- function minus() { var num1=document.Calform.One.value; var num2=document.Calform.Two.value; if(parseFloat(num1)<parseFloat(num2)) { alert("negative"); } else alert(parseFloat(num1)-parseFloat(num2)); //--> </script> <BODY> <FORM name="Calform"> <P> First Number:<INPUT TYPE="TEXT" NAME="One" maxlength="3"> Second Number:<INPUT TYPE="TEXT" NAME="Two" maxlength="3"> <INPUT TYPE="button" NAME="Minus" VALUE="Subtract" onclick="minus()"> <INPUT TYPE="RESET" VALUE="Reset!"> </FORM> </BODY> </HTML>

Loops For loop for(intialization;condition;increment) {statements} While loop while(codition){statements} Do while loop do{statements}while(condition) Keep on executing a code till a certain condition is met.

For Loop <HTML> <HEAD> <TITLE>Using the For Statement</TITLE> </HEAD> <BODY> <SCRIPT> <!-- for(i=1;i<7;i++) document.write("<H"+i+">Hello "+i+"!!</H"+i+">"); //-> </SCRIPT> </BODY> </HTML>

Some Predefined Objects Global Array String Math Date … etc.

Example of Math object <HTML> <HEAD> <TITLE>Using the Math object</TITLE> </HEAD> <BODY> <H1>Using the Math object </H1> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> <!-- document.write("Math.PI :" +Math.PI +"<P>"); document.write("Math.LN2 :"+Math.LN2+"<P>"); document.write("Math.sin(90) :"+Math.sin(90)+"<P>"); document.write("Math.random() :"+Math.random()+"<P>"); document.write("Math.pow(2,3) :"+Math.pow(2,3)+"<P>"); document.write("Math.min(123,133): "+Math.min(123,133)+"<P>"); //--> </SCRIPT> </BODY> </HTML>

Array Object <HTML> <HEAD> <TITLE>Using Arrays </TITLE> </HEAD> <BODY> <H1>Using Arrays </H1> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> <!-- myArray=[0,1,2,3,4,5,6,7,8,9,10]; document.write("myArray: first element " +myArray[0]+"<P>"); document.write("myArray.toString(): "+myArray.toString()+"<P>"); document.write("myArray.join(':'): "+myArray.join(':')+"<P>"); document.write("myArray.reverse(): "+myArray.reverse()+"<P>"); document.write("myArray.sort(): "+myArray.sort()+"<P>"); //--> </SCRIPT> </BODY> </HTML>