Web-based Application Development Lecture 18 March 21, 2006 Anita Raja.

Slides:



Advertisements
Similar presentations
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Advertisements

HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
The Web Warrior Guide to Web Design Technologies
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
CIS101 Introduction to Computing Week 12. Agenda Your questions Solutions to practice text Final HTML/JavaScript Project Copy and paste assignment JavaScript:
Web-based Application Development Lecture 9 February 7, 2006 Anita Raja.
JavaScript Forms Form Validation Cookies CGI Programs.
Tutorial 6 Working with Web Forms
Web-based Application Development Lecture 17 March 16, 2006 Anita Raja.
Loops – While, Do, For Repetition Statements Introduction to Arrays
Web-based Application Development Lecture 13 February 21, 2006 Anita Raja.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
Macromedia Dreamweaver 4 Advanced Level Course. Add Rollovers Rollovers or mouseovers are possibly the most popular effects used in designing Web pages.
JavaScript, Third Edition
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
Web-based Application Development Lecture 14 February 23, 2006 Anita Raja.
CIS101 Introduction to Computing Week 12 Spring 2004.
Introduction to JavaScript for Python Programmers
CST JavaScript Validating Form Data with JavaScript.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Web-based Application Development Lecture 7 January 31, 2006 Anita Raja.
JS Arrays, Functions, Events Week 5 INFM 603. Agenda Arrays Functions Event-Driven Programming.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
Tutorial 14 Working with Forms and Regular Expressions.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Chapter 3 : Processing on the Front End JavaScript Technically its name is ECMA-262, which refers to the international standard which defines it. The standard.
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.
Section 4.1 Format HTML tags Identify HTML guidelines Section 4.2 Organize Web site files and folder Use a text editor Use HTML tags and attributes Create.
Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and check boxes using HTML Add a pull-down.
Chapter 10 Fireworks: Part II The Web Warrior Guide to Web Design Technologies.
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
Using Client-Side Scripts to Enhance Web Applications 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
Chapter 5: Windows and Frames
Web-based Application Development Lecture 11 February 14, 2006 Anita Raja.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
CSCE 102 – Chapter 9 (Functions and Parameters) CSCE General Applications Programming Benito Mendoza Benito Mendoza 1 By Benito Mendoza.
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
L OO P S While writing a program, there may be a situation when you need to perform some action over and over again. In such situation you would need.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
JavaScript, Fourth Edition
JavaScript, Fourth Edition Chapter 4 Manipulating the Browser Object Model.
Loops Robin Burke IT 130. Outline Announcement: Homework #6 Conditionals (review) Iteration while loop while with counter for loops.
Loops.  (No Quiz)  Hand in Assignment #1  Last chance for Q+A on the midterm  Loops 2.
© 2011 Delmar, Cengage Learning Chapter 10 Using ActionScript to Enhance User Experience.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (NON-Audio version) © Dr. David C. Gibbs WDMD.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
Functions.  Assignment #2 is now due on Wednesday, Nov 25 th  (No Quiz)  Go over the midterm  Backtrack and re-cover the question about tracing the.
Input Boxes, List Boxes, and Loops Chapter 5. 2 Input Boxes Method for getting user’s attention to obtain input. InputBox() for obtaining input MessageBox()
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
JavaScript, Sixth Edition
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
HTML Structure II (Form) WEEK 2.2. Contents Table Form.
COM621: Advanced Interactive Web Development Lecture 6 – JavaScript (cont.)
Chapter 5 Validating Form Data with JavaScript
Programming the Web using XHTML and JavaScript
Programming the Web using XHTML and JavaScript
Web Programming and Design
Web Programming and Design
Presentation transcript:

Web-based Application Development Lecture 18 March 21, 2006 Anita Raja

Agenda Schedule Exam PTW Chapter 13

Exam Review List some ways to improve a site’s performance for users who have low bandwidth connections. Reduce # of images Compress images(thumbnails) Use text for navigation Why do sound and video files need to be compressed for use on a Web page? Takes too long to download List at least three ways to define the audience for a Web site. Age, gender, geography,income, education, race, interest, web history

Exam Review What elements of a site should be tested during technical testing? Browser, platform compatibility, bandwidth limitations How is text displayed, do images align with each other, are tables and frames arranged properly, Are sound, video anim, handled properly What are the five navigation questions that each page must answer for users? Whose site, where am I within the site, what else is avialable from this site, where should I go next, how do I get there, how do I find whatever I’m looking for Explain why scrolling is an important consideration in Web design. Capture all related info in one page Inefficient process (too many steps), web pages like TV not newspaper.

Frameset document Linking between frames TableOfContents.htm document Table of Contents: Click here to view document 1 in the bottom right frame Click here to view document 2 in the bottom left frame

Parameter Example function displayMessages(msg1,msg2,msg3) { alert(msg3); alert(“The first message is :” + msg1) alert(“The second message is” + msg2) } This is a sample page that uses Javascript, parameters and forms. displayMessages(“Ready?”, “Let’s go”, “Not yet”) <input type=“button” value= “Click here to see some more messages” onclick= “displayMessages(‘Here we go again’, ‘What did you say?’, ‘Time to go’)” />

Pop-Up Menus Quick links menus can be created using: The value attribute to hold URLs for each option The onchange event handler for the select element Ch12-Ex-13

More on forms … Include name attributes because The general form for information submitted via a form is: Name_Of_Form_Element = Value_Of_Information_Entered Ch12-Ex-14

More on forms …

Assignment Debugging Exercise, p. 364 Correct errors Add features to the form to Post corrected document to your Web space as “Lagerstrom-Ch-12.html” Grade based on: Appearance Technical correctness of code Proper results

Programming the Web using XHTML and JavaScript Chapter 13 Loops and Arrays

Repetitive Code Problem: the same code is repeated over and over but with minor changes How can this be implemented? A series of conditional statements … Consider a number of questions Meyers-Briggs personality test Each of which has three possible responses

Repetitive Code var scoreA=0, scoreB=0, scoreC=0 if (document.question1.choiceRB[0].checked) { scoreA=scoreA+1 } else if (document.question1.choiceRB[1].checked) { scoreB=scoreB+1 } else if (document.question1.choiceRB[2].checked) { scoreC=scoreC+1 }

Repetitive Code Conditional statements Take up a lot of room Offer multiple opportunities for typos Are hard to change later Is there a better alternative? Yes, loops A programming construct that controls the repetition of code

Three Types of Loops for loop Repeats a set of instructions for a number of times Basic syntax (pseudocode) for (some number of times) { execute this set of instructions }

Three Types of Loops “Some number of times” is the hard part JavaScript syntax: var ctr for (ctr=1; ctr<=5; ctr=ctr+1) { … } Starting value Counter Continuing condition Incrementing instruction

Three Types of Loops Sequence of events: 1. Set ctr to 1 2. Is ctr<=5? 3. If so, execute statements then continue at step 4. If not, exit loop and execute statement at step Increment ctr by adding the increment value 5. Is ctr<=5? 6. If so, execute statements then continue at step 4. If not, exit loop and execute statement at step Next statement following for block var ctr for (ctr=1; ctr<=5; ctr=ctr+1) { [statements to be executed] }

Three Types of Loops Ch14-Ex-01.html

Three Types of Loops Don’t have to start at one, any value will do: var ctr for (ctr=-27; ctr<=5; ctr=ctr+1) { … }

Three Types of Loops Can decrement also: var ctr for (ctr=5; ctr>1; ctr=ctr-1) { … }

Three Types of Loops Can increment or decrement by values other than one var ctr for (ctr=1; ctr<=100; ctr=ctr+5) { … }

Three Types of Loops Tips for for loops It’s for not For Separate statements with semicolons: for (ctr=1; ctr<=5; ctr=ctr+1) { … } ctr is not special, any variable can be used Remember the global/local nature of the counter The value of the counter when the loop completes is not necessarily the “stop” value

Three Types of Loops while loop Continues execution as long as a condition is true Good for situations where you don’t know exactly how many times the loop should be executed

Three Types of Loops Basic syntax (pseudocode) while (some condition is true) { execute these statements } Read “as long as”

Three Types of Loops Unlike a for loop, a while loop: Has no starting value Has no increment instruction The continuing condition is tested at the beginning of the loop

Three Types of Loops Because there is no starting condition or increment instruction the programmer must supply them: var ctr=0 while (ctr<=3) { ctr=ctr+1 alert(“The counter is “+ctr) }

Three Types of Loops Sequence of events: 1. Set ctr to 0 2. Is ctr<=3? 3. If so, increment ctr by one, execute the alert statement then continue at step 2. If not, exit loop and execute statement at step Next statement following while block Ch14-Ex-03.html var ctr=0 while (ctr<=3) { ctr=ctr+1 alert(“The counter is “+ctr) }

Three Types of Loops Infinite loops – repeat forever var ctr = 0 while ( ctr<2 ) { … ctr = ctr - 2 }

Three Types of Loops Another infinite loop var ctr = 0 while ( ctr<2 ) { … } ctr = ctr + 1

Three Types of Loops Another infinite loop var ctr for ( ctr=1; ctr<5; ctr++ ) { … ctr = 3 }

Three Types of Loops do-while loop Like while except test is at end instead of at beginning Basic syntax (pseudocode) do { these statements } while (some condition is true)

Three Types of Loops do-while is useful if you always want to execute the loop statements at least once

Arrays Single variables have limited usefulness Sometimes many of the same “type” of data need to be stored: Students Scores Questions, etc. The programming construct suited for this purpose is an array

Arrays Arrays are compound variables organized as an ordered collection of data The collection itself has a name The individual data items (“array elements”) are referred to by an index value

Arrays Array named sampleArray Element numbers “Hi” true-54.9 sampleArray[0] contains “Hi”

Arrays Arrays must be created Similar to declaring a variable Syntax (JavaScript): var sampleArray = new Array(5) Number of elements in sampleArray

Arrays Array elements are referred to by: The array name and The element number (or index) enclosed in square brackets: sampleArray[0] = “Hi” sampleArray[1] = … sampleArray[5] = -54.9

Arrays There is no implied order in assignment statements The element number is sufficient sampleArray[0] = “Hi” sampleArray[1] = is equivalent to sampleArray[1] = sampleArray[0] = “Hi”

Arrays The array size can be increased even after the array was constructed sampleArray[6]=false

Arrays There are two other ways of creating and filling an array var sampleArray = new Array (“Hi”, 39.72, 25, true, -54.9) or var sampleArray = [“Hi”, 39.72, 25, true, ]

Arrays Filling then displaying the contents of an array Ch14-Ex-05.html

Arrays An HTML form is like an array There are a certain number of elements Text boxes Radio buttons Check boxes, etc.

Arrays The following code: Creates a form like this:

Arrays document.namesForm.n1Box.value document.namesForm.n2Box.value document.namesForm.n3Box.value document.namesForm.n4Box.value

Arrays JavaScript treats a form like an array Each element can be referred to by its Name or Position in the form This is the elements array The first element in an array is element[0], the second is element[1], etc.

Arrays Ch14-Ex-06.html

Arrays JavaScript also provides a forms array Same as an elements array except it numbers the forms in a document The first form is forms[0], the second form is forms[1], etc. Ch14-Ex-07.html

Arrays document.namesForm.elements[0].value document.namesForm. elements[1].value document.namesForm. elements[2].value document.namesForm. elements[3].value

Assignment Debugging Exercise, p. 421 Correct errors Post corrected document to your Web space as “Lagerstrom-Ch-14.html” Grade based on: Appearance Technical correctness of code Proper results