Client-Side Programming with JavaScript: Understanding Scripting in HTML and Common Tasks, Exams of Financial Accounting

An overview of client-side programming using javascript, including the benefits of using javascript, how it is embedded in html documents, common scripting tasks, and its limitations. It also covers the use of external and internal scripts, as well as data types and variables in javascript.

Typology: Exams

2014/2015

Uploaded on 10/20/2015

abhideep_sinha
abhideep_sinha 🇮🇳

1 document

1 / 36

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
JavaScript
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24

Partial preview of the text

Download Client-Side Programming with JavaScript: Understanding Scripting in HTML and Common Tasks and more Exams Financial Accounting in PDF only on Docsity!

JavaScript

Introduction

 A script is a small piece of program that can add

interactivity to your website. For example, a script

could generate a pop-up alert box message, or provide a

dropdown menu. This script could be written using

Javascript or VBScript.

 You can write various small functions, called event

handlers using any of the scripting language and then

you can trigger those functions using HTML attributes.

 You can keep Javascript code in a separate file and then

include it whereever it's needed, or you can define

functionality inside HTML document itself.

Common Scripting Tasks

 (^) adding dynamic features to Web pages ◦ (^) validation of form data (probably the most commonly used application) ◦ (^) image rollovers ◦ (^) time-sensitive or random page elements ◦ (^) handling cookies ◦ (^) utilize buttons, text boxes, clickable images, prompts, etc  (^) limitations of client-side scripting  (^) since script code is embedded in the page, it is viewable to the world  (^) for security reasons, scripts are limited in what they can do  (^) e.g., can't access the client's hard drive  (^) since they are designed to run on any machine platform, scripts do not contain platform specific commands  (^) script languages are not full-featured  (^) e.g., JavaScript objects are very crude, not good for large project development

External Javascript

If you are going to define a functionality which will be

used in various HTML documents then it's better to keep

that functionality in a separate Javascript file and then

include that file in your HTML documents.

A Javascript file will have extension as .js and it will be

included in HTML files using

Internal

You can write your script code directly into your HTML

document. Usually we keep script code in header of the

document using

Example

Javascript Internal Script

DataType and variables

JavaScript has only three primitive data types

String : "foo" 'how do you do?' "I said 'hi'." Number : 12 3.14159 1.5E Boolean : true false (Null, Undefined have special meaning in JavaScipt)

 assignments are as in C++/Java

◦ (^) message = "howdy"; ◦ (^) pi = 3.14159;  (^) variable names are sequences of letters, digits, and underscores that start with a letter or an underscore  (^) variables names are case-sensitive  (^) you don't have to declare variables, will be created the first time used, but it’s better if you use var statements (because of scoping issues)  (^) var message, pi=3.14159;  (^) variables are loosely typed, can be assigned different types of values (Danger!)

Example

Data Types and Variables

Set the variable to different value and then try...

   

Set the variable to different value and then try...

 (^)

 (^)  (^)  (^)  (^)

Set the variable to different value and then try...

Set the variable to different value and then try...

Set the variable to different value and then

try...

Output: Entering the loop  (^2)  (^3)  (^4)  (^6)  (^7)  (^8)  (^9)  (^10)  (^) Exiting the loop!