CC1003N Week 6 More CSS and Javascript.. Objectives: ● More CSS Examples ● Javascript – introduction ● Uses of Javascript ● Variables ● Comments ● Control.

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

Sue Wills July Objects The JavaScript language is completely centered around objects, and because of this, it is known as an Object Oriented Programming.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Javascript Introduction Norman White Material is from w3schools.com Go there to run examples interactively.
The Web Warrior Guide to Web Design Technologies
Chapter 6 Basic forms 1. Forms and query string 2 form : a group of user input (UI) controls that accepts information from the user and sends the information.
HTML Forms JavaScript Introduction / Overview Lab Homework #1 CS 183 4/8/2010.
Web Page Behavior IS 373—Web Standards Todd Will.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Web Programming Material From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web 1 Introduction The JavaScript Programming.
آموزش طراحی وب سایت جلسه دهم – جاوا اسکریپت 1 تدریس طراحی وب برای اطلاعات بیشتر تماس بگیرید تاو شماره تماس: پست الکترونیک :
Client-Side programming with JavaScript 3
Javascript and the Web Whys and Hows of Javascript.
JavaScript Form Validation
Introduction to JavaScript. JavaScript Facts A scripting language - not compiled but interpreted line by line at run-time. Platform independent. It is.
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
DOM and JavaScript Aryo Pinandito.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
Doman’s Sections Information in this presentation includes text and images from
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.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
What is Java Script? An extension to HTML. An extension to HTML. Allows authors to incorporate some functionality in their web pages. (without using CGI.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
Intro to JavaScript. Some simple examples Examples from our webpage Examples from Andrews webpage Today’s Example.
1 JavaScript
ECA225 Applied Interactive Programming Cascading Style Sheets, pt 1 ECA 225 Applied Online Programming.
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
Introduction to JavaScript CS101 Introduction to Computing.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
Introduction To JavaScript. Putting it Together (page 11) All javascript must go in-between the script tags. All javascript must go in-between the script.
COMP403 Web Design JAVA SCRİPTS Tolgay KARANFİLLER.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Pertemuan 5 IT133 Pengembangan Web JavaScript. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
Creating Web Documents: JavaScript Ftp / file management: review Introduction to JavaScript Sources Homework: start review for midterm, work on Project.
Introduction to JavaScript CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Web Development JavaScript. Introduction to JavaScript.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
JavaScript Tutorial First lecture 19/2/2016. Javascript is a dynamic computer programming language. It is lightweight and most commonly used as a part.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
© 2010 Robert K. Moniot1 Chapter 6 Introduction to JavaScript.
Java Script Introduction. Java Script Introduction.
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript.
Web Programming– UFCFB Lecture 17
JavaScript What is JavaScript? What can JavaScript do?
CS105 Introduction to Computer Concepts
JavaScript What is JavaScript? What can JavaScript do?
Tutorial 10: Programming with javascript
Web Programming and Design
Web Programming and Design
CS105 Introduction to Computer Concepts JavaScript
Presentation transcript:

CC1003N Week 6 More CSS and Javascript.

Objectives: ● More CSS Examples ● Javascript – introduction ● Uses of Javascript ● Variables ● Comments ● Control structure ● Functions ● Objects in Javascript ● Date Object ● Form validation

Styling Hyperlinks A:link { FONT-WEIGHT: normal; COLOR: #336699; TEXT-DECORATION: underline } A:visited { FONT-WEIGHT: bold; COLOR: #336699; TEXT-DECORATION: underline } A:hover{ TEXT-DECORATION: underline; background-color: #FFFFFF; }

Class Selector CSS Classes p.section1 {color:blue; font-size:20pt} p.section2 {color:green; font-size:16pt} p.section3 {color:magenta; font-size:12pt} This is section 1 This is section 2 This is section 3

Anonymous classes CSS Classes.section1 {color:blue; font-size:20pt}.section2 {color:green; font-size:16pt}.section3 {color:magenta; font-size:12pt} This is section 1 This is section 2 This is section 3

Division The tag defines a division/section in a document. Example This is a header in a div section This is a paragraph in a div section

Navigation menu ul { float:left; width:100%; padding:0; margin:0; list-style-type:none; } a { float:left; width:6em; text-decoration:none; color:white; background-color:purple; padding:0.2em 0.6em; border-right:1px solid white; } a:hover {background-color:#ff3300} li {display:inline} Link one Link two Link three Link four Example !

Javascript ● JavaScript was designed to add interactivity to HTML pages ● JavaScript is a scripting language ● A scripting language is a lightweight programming language ● Everyone can use JavaScript without purchasing a license

Uses of Javascript ● JavaScript gives HTML designers a programming tool ● JavaScript can react to events - A JavaScript can be set to execute when something happens, like when a page has loaded or when a user clicks on an HTML element ● JavaScript can read and write HTML elements – A JavaScript can read and change the content of an HTML element ● JavaScript can be used to validate data – A JavaScript can be used to validate form data before it is submitted to a server. This saves the server from extra processing

Using Javascript inside HTML ● The HTML tag is used to insert a JavaScript into an HTML page. some Javascript here......

Events ● onload ● onclick ● onsubmit ● onreset ● Example :

Variables ● variables are used to hold values or expressions. ● Rules for JavaScript variable names: ● Variable names are case sensitive (y and Y are two different variables) ● Variable names must begin with a letter or the underscore character. ● Examples of variables ● Declaring variables:var name; var id; ● Initializing variables:var name=”Islington”; var id=20; ● When you assign a text value to a variable, use quotes around the value

var name; name=“Islington”; document.write(name); document.write(" "); name=“Computer”; document.write(name);

Comments ● Single line comment // this is a single line comment ● Multi-line comment /* this is a multi-line comment */

Javascript arithmetic ● var a=5; ● var b=20; ● var c = b-a; ● var d = a+b;

Control structure – loop ● for loop for(variable=startvalue;variable<=endvalue;variable=variable+incremen t) { code to be executed }

for loop(Contd..) var i=0; for (i=0;i<=5;i++) { document.write("The number is " + i); document.write(" "); }

while loop while (variable<=endvalue) { code to be executed }

while loop(Contd..) var i=0; while (i<=5) { document.write("The number is " + i); document.write(" "); i++; }

do....while loop do { code to be executed } while (variable<=endvalue);

do....while loop(Contd..) var i=0; do { document.write("The number is " + i); document.write(" "); i++; } while (i<=5);

Control structure - decision if (condition) { code to be executed if condition is true } else{ code to be executed if condition is false }

Control structure – decision (contd….) var d=new Date(); var time=d.getHours(); if (time<10) { document.write(" Good morning "); } Else document.write(" Good afternoon ");

Functions ● A function contains code that will be executed by an event or by a call to the function. ● You may call a function from anywhere within a page (or even from other pages if the function is embedded in an external.js file). ● Functions can be defined both in the and in the section of a document. However, to assure that a function is read/loaded by the browser before it is called, it could be wise to put functions in the section.

Defining functions function functionname(var1,var2,...,varX) { some code } ● The parameters var1, var2, etc. are variables or values passed into the function. The { and the } defines the start and end of the function.

Example of function function displaymessage() { alert("Hello World!"); }

return statement ● The return statement is used to specify the value that is returned from the function. function product(a,b) { return a*b; } document.write(“result = ” product(4,3));

Objects in Javascript ● Objects in Javascript JavaScript is an Object Oriented Programming (OOP) language. JavaScript has built-in objects. Objects have different methods in it. Example: method var str="Hello world!"; document.write(str.toUpperCase()); Output:HELLO WORLD!

Date Object ● The Date object is used to work with dates and times. ● Date objects are created with the Date() constructor. ● There are differrent ways of instantiating a date: new Date() // current date and time new Date(year, month, day, hours, minutes, seconds, milliseconds)

Opening a new window ● The open() method opens a new browser window. - window.open(URL)

Opening a new window(Contd..) function open() { window.open(" }

window.open() – URL of new page – Name of new page – Feature string e.g. sizes ● E.g. window.open ("page1.html", "_parent","width=100, height=150");

Form validation ● JavaScript can be used to validate data inHTML forms before sending off the content to a server. ● Form data that typically are checked by a JavaScript could be: has the user left required fields empty? has the user entered a valid address? has the user entered a valid date? has the user entered text in a numeric field?

Form validation(Contd..) Create function to validate data Call the function when submitting the form <form onsubmit="return myvalidate()"... Alert if errors

Form validation(Contd..) function validateForm(form) { var x=form.fname.value; if (x==null || x=="") { alert("First name must be filled out"); } <form name="nameForm" action="first.html" onsubmit="return validateForm(nameForm)" method="post"> First name: <input type="text" name="fname"> <input type="submit" value="Submit">