CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT

Slides:



Advertisements
Similar presentations
Computer Science 103 Chapter 3 Introduction to JavaScript.
Advertisements

Information Technology Center Hany Abdelwahab Computer Specialist.
Computer Science 103 Chapter 4 Advanced JavaScript.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
CSC317 – INTERNET PROGRAMMING CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: MUHD EIZAN SHAFIQ BIN ABD AZIZ FACULTY of COMPUTER and MATHEMATICAL SCIENCES.
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT
CSC318 – WEB APPLICATION DEVELOPMENT BY: MUHD EIZAN SHAFIQ BIN ABD AZIZ FACULTY of COMPUTER and MATHEMATICAL SCIENCES.
The Document Object Model. Goals Understand how a JavaScript can communicate with the web page in which it “lives.” Understand how to use dot notation.
JavaScript Part 1.
CC1003N Week 6 More CSS and Javascript.. Objectives: ● More CSS Examples ● Javascript – introduction ● Uses of Javascript ● Variables ● Comments ● Control.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
CSC317 – INTERNET PROGRAMMING CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: MUHD EIZAN SHAFIQ BIN ABD AZIZ FACULTY of COMPUTER and MATHEMATICAL SCIENCES.
ALBERT WAVERING BOBBY SENG. Week 4: JavaScript  Quiz  Announcements/questions.
1 CSC317/318 INTERNET PROGRAMING / DYNAMIC WEB APPLICATION DEVELOPMENT Siti Nurbaya Ismail Faculty of Computer & Mathematical Sciences, Universiti Teknologi.
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES.
JavaScript, Fourth Edition
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
CSC317 – INTERNET PROGRAMMING CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Tutorial 11 1 JavaScript Operators and Expressions.
Scripting with Client-Side Processing Scripting with Client Side Processing Lesson – Web Technologies Copyright © Texas Education Agency, All rights.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
Learning Javascript From Mr Saem
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
JavaScript Tutorial First lecture 19/2/2016. Javascript is a dynamic computer programming language. It is lightweight and most commonly used as a part.
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.
PHP using MySQL Database for Web Development (part II)
Build in Objects In JavaScript, almost "everything" is an object.
Java Script Introduction. Java Script Introduction.
>> Introduction to JavaScript
CHAPTER 10 JAVA SCRIPT.
Web Systems & Technologies
Chapter 6 JavaScript: Introduction to Scripting
Web Development & Design Foundations with HTML5
HTML & teh internets.
EXCEPTION HANDLING IN SERVER CLIENT PROGRAMMING
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
JavaScript Syntax and Semantics
Chapter 6: Conditional Statements and Loops
BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES
JavaScript.
CHAPTER 4 CLIENT SIDE SCRIPTING PART 2 OF 3
14 A Brief Look at JavaScript and jQuery.
BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Exercises on JavaScript & Revision
Client side & Server side scripting
BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES
Introduction to JavaScript for Python Programmers
T. Jumana Abu Shmais – AOU - Riyadh
Faculty of Computer Science & Information System
CS105 Introduction to Computer Concepts
BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES
M150: Data, Computing and Information
CSC318 – WEB APPLICATION DEVELOPMENT
Tutorial 10: Programming with javascript
Web Programming– UFCFB Lecture 13
Programming Basics Review
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
JavaScript 101 Lesson 8: Loops.
Presentation transcript:

CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: MUHD EIZAN SHAFIQ BIN ABD AZIZ FACULTY of COMPUTER and MATHEMATICAL SCIENCES

Outline Basic JavaScript For Loop While Loop Do While Loop User-defined Function Working with Web Pages Properties Error Checking FSKM UiTM Pahang  Page 2

Basic JavaScript For Loop Execute the same block of code according specified times for(var = startValue; var <= endValue; var = var + increment){ // execute the block code until var = endValue } var x; for(x = 0; x <= 10; x++){ document.write("Number: " + x + "<br>"); } FSKM UiTM Pahang  Page 3

Quit looping & continue the rest of the program for loop for (initialization; condition; update) {   statements; } 1 4 A B D 2, TRUE 3 C FALSE Quit looping & continue the rest of the program EA | CSC128 | TOPIC04 2/19/2019

Basic JavaScript For Loop Another example on for loop var x; var msg = "UiTM Pahang."; for(x = 1; x <= 5; x++){ document.write(msg + " " + x + "<br>"); } FSKM UiTM Pahang  Page 5

Basic JavaScript For Loop Output tracing count count <= 5 Statement 1 T UiTM Pahang 1 2 UiTM Pahang 2 3 UiTM Pahang 3 4 UiTM Pahang 4 5 UiTM Pahang 5 6 F stop looping at count 6 FSKM UiTM Pahang  Page 6

Basic JavaScript While Loop Execute the same block of code while a specific condition is true while(var <= endValue){ // execute the code } var x = 0; while(x <= 10){ document.write("Number: " + x + "<br>"); x++; // x = x + 1 } FSKM UiTM Pahang  Page 7

Basic JavaScript While Loop Another example on while loop var month_name, month = 1; while(month <= 3){ if(month == 1){ month_name = "January"; } else if(month == 2){ month_name = "February"; else if(month == 3){ month_name = "March"; else{ alert("Please select month! "); month = month + 1; FSKM UiTM Pahang  Page 8

Basic JavaScript Do...While Loop Execute the block of code at least once even the condition is false, because the code will be executed first before condition is tested. It will repeat the loop as long as the specified condition is true. do{ // execute the code } while(var <= endValue) var x = 0; do{ document.write("Number is: " + x + "<br>"); x = x + 1; } while(x < 0) FSKM UiTM Pahang  Page 9

Basic JavaScript User-defined Function A function created by user to perform specific task <html> <head> <script type="text/javascript"> function myFunction(){ var msg = "Hello World!"; return (msg); } </script> </head> <body> document.write(myFunction()); </body> </html> FSKM UiTM Pahang  Page 10

Basic JavaScript User-defined Function Create an HTML document using Notepad Create an HTML form Create 1 text field, name it as “num1”, label it as “Number 1” Create 1 text field, name it as “num2”, label it as “Number 2” Create 1 drop down list, name it as “operator”, label it as “Operator” Create options for drop down list above (+, -, /, *), where, arithmetic symbols will be displayed, while, arithmetic descriptions (add, minus, divide, times) as values Create 1 text field, name it as “total”, label it as “Total” Create 1 button, set the type as “button”, and, place onclick event to trigger calculate()function FSKM UiTM Pahang  Page 11

Basic JavaScript User-defined Function Create JavaScript function inside <head> tag Create user-defined function name calculate() Write codes to capture inputs from num1, num2, and operator input fields and assign to variables num1, num2, and operator Do not forget to parse user inputs for num1 and num2. you may use parseInt() or parseFloat() Declare a variable name total Since you have captured value of operator, use if...else if... statement to perform calculation of num1 and num2 based on operator The result of calculation will be assigned to variable total FSKM UiTM Pahang  Page 12

Basic JavaScript User-defined Function Use variable total which hold the result, to display the output on total text field This is mine! ;-) Source Code Actual Example FSKM UiTM Pahang  Page 13

Basic JavaScript Working with Web Pages Properties May be you are not realized that you have used Web Pages properties (or Document properties) a few times Example: document.write(): to display information on the web page We have others like: document.bgColor: Example | Source Code document.fgColor: Example | Source Code document.lastModified: Example | Source Code FSKM UiTM Pahang  Page 14

Basic JavaScript Error Checking Remember this example? <html> <head> <script type="text/javascript"> function myFunction(){ var fname = document.form1.fname.value; alert("Name: " + fname); } </script> </head> <body> <form name="form1"> Name: <input type="text" name="fname"> <input type="submit" name="submit" value="Submit" onclick="myFunction()"> </form> </body> </html> FSKM UiTM Pahang  Page 15

Basic JavaScript Error Checking myFunction() will capture a value from fname text field. This field is specifically for people´s name, which is string value What will happen if user enter numeric value? Should myFunction() accept the value without need to do error checking? What will happen if user does not enter any value? The field leave blank <script type="text/javascript"> function myFunction(){ var fname = document.form1.fname.value; alert("Name: " + fname); } </script> FSKM UiTM Pahang  Page 16

Basic JavaScript Error Checking <script type="text/javascript"> function myFunction(){ var fname = document.form1.fname.value; if(fname == ""){ // check if no value being entered alert("Please enter a name!"); } else if(fname == null){ // check if there is undefined value else if(!isNaN(fname)){ // check if value is numeric alert("Invalid character. Name must be alphabet."); else{ // all conditions above false document.write("Name: " + fname); </script> FSKM UiTM Pahang  Page 17

Basic JavaScript Error Checking fname = ″″ and fname = null are two different statements fname = ″″: check if the value is empty fname = null: check if the value is null (undefined or unknown) FSKM UiTM Pahang  Page 18

Question? FSKM UiTM Pahang  Page 19 FSKM UiTM Pahang  Page 19 19

Bibliography (Website) Bibliography (Book) Knuckles (2001). Introduction to Interactive Programming on the Internet using HTML & Javascript. John Wiley & Sons, Inc. http://www.w3schools.com/js/default.asp Bibliography (Website) FSKM UiTM Pahang  Page 20 FSKM UiTM Pahang  Page 20 20