Lab 5 Introduction to Java Scripts



Similar documents
JavaScript: Introduction to Scripting Pearson Education, Inc. All rights reserved.

JavaScript: Control Statements I

JavaScript: Arrays Pearson Education, Inc. All rights reserved.

Further web design: HTML forms

c. Write a JavaScript statement to print out as an alert box the value of the third Radio button (whether or not selected) in the second form.

JavaScript and Dreamweaver Examples

Website Login Integration

Script Handbook for Interactive Scientific Website Building

Yandex.Widgets Quick start

Using Form Tools (admin)

In order for the form to process and send correctly the follow objects must be in the form tag.

Reading an sent with Voltage Secur . Using the Voltage Secur Zero Download Messenger (ZDM)

Intell-a-Keeper Reporting System Technical Programming Guide. Tracking your Bookings without going Nuts!

InternetVista Web scenario documentation

Viewing Form Results

HTML Form Widgets. Review: HTML Forms. Review: CGI Programs

PHP Tutorial From beginner to master

DeltaPAY v2 Merchant Integration Specifications (HTML - v1.9)

Internet Technologies

Dynamic Web-Enabled Data Collection

Introduction to Java Applets (Deitel chapter 3)

Client-side Web Engineering From HTML to AJAX

FORM-ORIENTED DATA ENTRY

Abusing HTML5. DEF CON 19 Ming Chow Lecturer, Department of Computer Science TuCs University Medford, MA

WIRIS quizzes web services Getting started with PHP and Java

ANGULAR JS SOFTWARE ENGINEERING FOR WEB SERVICES HASAN FAIZAL K APRIL,2014

LAB MANUAL CS (22): Web Technology

2- Forms and JavaScript Course: Developing web- based applica<ons

Installation and Integration Manual TRANZILA Secure 5

<?php if (Login::isLogged(Login::$_login_front)) { Helper::redirect(Login::$_dashboard_front); }

JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK

1 crossover cable. the PCs. network

Multimedia im Netz Online Multimedia Winter semester 2015/16. Tutorial 03 Major Subject

Modern browsers support many technologies beyond (X)HTML, CSS, and JavaScript.

JAVASCRIPT AND COOKIES

JavaScript Basics & HTML DOM. Sang Shin Java Technology Architect Sun Microsystems, Inc. sang.shin@sun.com

Novell Identity Manager

WebSphere Business Monitor V7.0 Script adapter lab

<option> eggs </option> <option> cheese </option> </select> </p> </form>

«W3Schools Home Next Chapter» JavaScript is THE scripting language of the Web.

CS412 Interactive Lab Creating a Simple Web Form

XHTML Forms. Form syntax. Selection widgets. Submission method. Submission action. Radio buttons

Web Development CSE2WD Final Examination June (a) Which organisation is primarily responsible for HTML, CSS and DOM standards?

Understanding Cross Site Scripting

Using GeoGebra to create applets for visualization and exploration.

Web Programming Step by Step

InPost UK Limited GeoWidget Integration Guide Version 1.1

Direct Post Method (DPM) Developer Guide

MASTERTAG DEVELOPER GUIDE

SEEM4540 Open Systems for E-Commerce Lecture 06 Online Payment

Dynamic Web Pages With The Embedded Web Server. The Digi-Geek s AJAX Workbook

Chapter 22 How to send and access other web sites

Working with forms in PHP

UPG plc Atlas Technical Integration Guide

07 Forms. 1 About Forms. 2 The FORM Tag. 1.1 Form Handlers

TCP/IP Networking, Part 2: Web-Based Control

CS170 Lab 11 Abstract Data Types & Objects

Forms, CGI Objectives. HTML forms. Form example. Form example...

Finding XSS in Real World

Chapter 2: Interactive Web Applications

Spectrum Technology Platform

Government Girls Polytechnic, Bilaspur

Hello World RESTful web service tutorial

PHP Form Handling. Prof. Jim Whitehead CMPS 183 Spring 2006 May 3, 2006

Chulalongkorn University International School of Engineering Department of Computer Engineering Computer Programming Lab.

Cover Page. Dynamic Server Pages Guide 10g Release 3 ( ) March 2007

Web Programming with PHP 5. The right tool for the right job.

Inserting the Form Field In Dreamweaver 4, open a new or existing page. From the Insert menu choose Form.

Building Web Applications with HTML5, CSS3, and Javascript: An Introduction to HTML5

Client Side Binding of Dynamic Drop Downs

Performance Testing for Ajax Applications

Website Planning Checklist

Real SQL Programming 1

Online signature API. Terms used in this document. The API in brief. Version 0.20,

Login with Amazon. Getting Started Guide for Websites. Version 1.0

Dynamic Web Pages With The Embedded Web Server. The Rabbit-Geek s AJAX Workbook

Web application development (part 2) Netzprogrammierung (Algorithmen und Programmierung V)

Implementing Specialized Data Capture Applications with InVision Development Tools (Part 2)

A table is a collection of related data entries and it consists of columns and rows.

Fortigate SSL VPN 4 With PINsafe Installation Notes

SQL Injection for newbie

Introduction to Visual C++.NET Programming. Using.NET Environment

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

Technical University of Sofia Faculty of Computer Systems and Control. Web Programming. Lecture 4 JavaScript

Overview. In the beginning. Issues with Client Side Scripting What is JavaScript? Syntax and the Document Object Model Moving forward with JavaScript

It is highly recommended that you are familiar with HTML and JavaScript before attempting this tutorial.

A GENERIC APPROACH TO USER INTERFACE CODE CONVERSION

AJAX and JSON Lessons Learned. Jim Riecken, Senior Software Engineer, Blackboard Inc.

PHP Authentication Schemes

Chapter 2 HTML Basics Key Concepts. Copyright 2013 Terry Ann Morris, Ed.D

Advanced Web Technology 10) XSS, CSRF and SQL Injection 2

Now that we have discussed some PHP background

HTML Forms and CONTROLS

Transcription:

King Abdul-Aziz University Faculty of Computing and Information Technology Department of Information Technology Internet Applications CPIT405 Lab Instructor: Akbar Badhusha MOHIDEEN Lab 5 Introduction to Java Scripts Objectives: The objective of this lab is to learn about the use of Java scripts in the HTML Document. In this lab we will learn about how to: print of text using JavaScript document object (writeln) prompt the user for input using JavaScript window object (prompt) convert the input text to integer using JavaScript parseint() function use the selection structure and repetition structure in the java script. Validate the user input. Outline of this lab: Printing: JavaScript document object (writeln) Prompting: JavaScript window object (prompt) Parsing: JavaScript parseint() function Selection Structure: if statement Repetition Structure: while statement Arrays: Use of arrays in Java Scripts Input Validation: Validate input using nested if statements In lab Assignments and Home works Activity Outcomes At the end of this lab the student will be able to write simple java scripts including the I/O statements, selection statements, repetition statements, arrays and input validation. Lab Tasks JavaScript document object (writeln) Execute the following HTML code and observe the output in the browser <title>a First Program in JavaScript</title> document.writeln("<h1>welcome to JavaScript Programming!</h1>" ); --> 1

JavaScript window object (prompt) Execute the following HTML code and observe the output in the browser <title>using Prompt and Alert Boxes</title> var name; name = window.prompt( "Please enter your name" ); document.writeln( "<h1>hello " + name + ", welcome to JavaScript programming!</h1>" ); --> <p>click Refresh (or Reload) to run this script again.</p> JavaScript parseint() function 1. Execute the following HTML code and observe the output in the browser <title>an Addition Program</title> var firstnumber; // first string entered by user var secondnumber; // second string entered by user var number1; // first number to add var number2; // second number to add var sum; // sum of number1 and number2 // read in first number from user as a string firstnumber = window.prompt( "Enter first integer" ); // read in second number from user as a string secondnumber = window.prompt( "Enter second integer" ); // convert numbers from strings to integers number1 = parseint( firstnumber ); number2 = parseint( secondnumber ); sum = number1 + number2; // add the numbers // display the results document.writeln( "<h1>the sum is " + sum + "</h1>" ); <p>click Refresh (or Reload) to run the script again</p> 2

If statement <title>finding Code Errors</title> var gender; gender = window.prompt( "Enter gender " + "(1=Woman,2=Man)", "1" ); if ( gender == 1 ) document.writeln( "Woman"); document.writeln( "Man" ); While statement <title>class Average Program</title> var total; var gradecounter; var grade; var gradevalue; var average; total = 0; gradecounter = 1; while ( gradecounter <= 4 ) grade = window.prompt( "Enter integer grade:"+ gradecounter, "0" ); gradevalue = parseint( grade ); total = total + gradevalue; gradecounter = gradecounter + 1; 3

average = total / 4; document.writeln("<h1>class average is " + average + "</h1>" ); <p>click Refresh (or Reload) to run the script again</p> JavaScript validation <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <script type="text/javascript"> function validate() if(document.form1.username.value!="") if(document.form1.password.value!="") document.form1.submit() alert("enter the password!?"); document.form1.password.focus(); alert("enter the username!?"); document.form1.username.focus(); //--> <form name="form1" method="post"> Username : <input name="username" type="text" /><br/> Password : <input name="password" type="password" /><br/> <input name="btn1" type="button" value="login" onclick="validate();" /> 4

</form> Assignment 1 Write a JavaScript code to prompt the user to input the marks of 5 subjects of a student. Display if he has passed in each subject if mark is above 60. Find the average of all subjects and print it. Assignment 2 Build a numerical calculator. Ask user for two inputs (numbers). Ask user for what function to perform 1. Addition, 2. Subtraction, 3. Multiplication and 4. Division. Display the result accordingly. 5