Loop Lab CSD 340 (Blum).

Slides:



Advertisements
Similar presentations
กระบวนวิชา CSS. What is CSS? CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to.
Advertisements

Tutorial 4: Designing a Web Page with Tables
CSD 340 (Blum)1 Using Microsoft Visual Studio.NET Development Environment and Introducing Functions.
14/11/11.  These words have special meanings in themselves  These should NOT be used as Identifiers.  For example:  Break, do, function, case, else,
10-Jun-15 Just Enough Java. Variables A variable is a “box” that holds data Every variable has a name Examples: name, age, address, isMarried Variables.
Java Applets A lab course by Dr. Junaid Ahmed Zubairi SUNY Fredonia.
Web Page Creation Part II ST: Introduction to Web Interface Design Prof. Angela Guercio Spring 2007.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements II.
Web Page Creation Part II ST: Introduction to Web Interface Design Prof. Angela Guercio.
Division Algorithm Let (x) and g(x) be polynomials with g(x) of lower degree than (x) and g(x) of degree one or more. There exists unique polynomials.
Explanation of Web 6, Web 7 and Web 9 at my site Please be sure to bring up the speaker notes for the explanation Intro - Web 6, Web 7 and Web 9.
Learning HTML. HTML Attributes HTML elements can have attributes Attributes provide additional information about an element Class – specifies a class.
EGR 2261 Unit 5 Control Structures II: Repetition  Read Malik, Chapter 5.  Homework #5 and Lab #5 due next week.  Quiz next week.
INTRODUCTION TO HTML5 Styling Text. Change the Font Size  You can use the font-size property to change the font size for a document’s text.  Instead.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
CSD 340 (Blum)1 Ifs. CSD 340 (Blum)2 Page that asks user for background color and changes fore color from black if user selects black as background color.
TH EDITION LIAL HORNSBY SCHNEIDER COLLEGE ALGEBRA.
CSD 340 (Blum)1 Using Visual Studio CSD 340 (Blum)2 Start/Microsoft Visual Studio 2005/Microsoft Visual Studio 2005.
ECA 228 Internet/Intranet Design I Tables. ECA 228 Internet/Intranet Design I Basic HTML Tables Created as a way to present rows and clumns of data.
Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.
CSD 340 (Blum)1 Switch and While. CSD 340 (Blum)2 From if to switch.
CSD 340 (Blum)1 Starting JavaScript Homage to the Homage to the Square.
CSD 340 (Blum)1 Drop-down list and timers. CSD 340 (Blum)2 Double click on the drop-down list icon to place one on the page.
February ,  2/16: Exam 1 Makeup Papers Available  2/20: Exam 2 Review Sheet Available in Lecture  2/27: Lab 2 due by 11:59:59pm  3/2:
X + 5 4x +20x R + 3 3x x Tues 11/24 Lesson 5 – 4 Learning Objective: To divide polynomials by synthetic division Hw: Pg. 308 #21-29.
CSD 340 (Blum)1 Starting JavaScript Homage to the Homage to the Square.
CSD 340 (Blum)1 Arrays See Beginning JavaScript pp
CSD 340 (Blum)1 For Loops See Beginning JavaScript (Paul Wilton) p. 87.
CSD 340 (Blum)1 Introducing Text Input elements and Ifs.
JavaScript 101 Lesson 6: Introduction to Functions.
Learning Javascript From Mr Saem
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
GCSE COMPUTER SCIENCE Practical Programming using Python
CSS Colors, JavaScript Variables, Conditionals and Basic Methods
Copyright © 2013, 2009, 2005 Pearson Education, Inc.
Lecture 4b Repeating With Loops
The Box Model in CSS Web Design – Sec 4-8
4.01 Cascading Style Sheets
The Box Model in CSS Web Design – Sec 4-8
CSS Layouts: Grouping Elements
Loops BIS1523 – Lecture 10.
Lesson 4 - Challenges.
Muybridge Lab CSD 340 (Blum).
Introduction to For Loops
ITM 352 Expressions, Precedence, Working with Strings Class #5
Lecture 07 More Repetition Richard Gesick.
Tag Basics.
Lecture 4B More Repetition Richard Gesick
Functions BIS1523 – Lecture 17.
File Handling Programming Guides.
Number and String Operations
Lesson 2: Input and Variables
Chapter (3) - Looping Questions.
T. Jumana Abu Shmais – AOU - Riyadh
CMSC 202 Java Primer 2.
Objective The student will be able to:
Programming Control Structures with JavaScript Part 2
Select tags CSD 340 (Blum).
For this assignment, copy and past the XHTML to a notepad file with the .html extension. Then add the code I ask for to complete the problems.
Loops and Arrays in JavaScript
JavaScript: Arrays.
February , 2009 CSE 113 B.
Just Enough Java 17-May-19.
4.01 Cascading Style Sheets
Web Programming and Design
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.
Intro to Programming (in JavaScript)
Presentation transcript:

Loop Lab CSD 340 (Blum)

Start with the HTML for a gray rectangle Start with Template.htm, Use Save As to give the file another name. The HTML for a gray rectangle division is: <div style="height: 60px; width: 40px; position: absolute; top:10px; left: 30px; background: #777777" ms_positioning="GridLayout"></div> Declare a JavaScript variable and assign the above string to it (remember to replace quotes with backslash quotes). Then write it to the document. CSD 340 (Blum)

So far we have: (I choose a black background) CSD 340 (Blum)

Repetition Write a for loop that concatenates together 5 copies of the gray rectangle HTML code and write it to the document. Add an alert inside the loop that displays the HTML you should be the code grow longer and longer. CSD 340 (Blum)

CSD 340 (Blum)

All 5 rectangles have the same top and left attributes so they all are in the same place and we only see one. CSD 340 (Blum)

Changing position Instead of having each rectangle have the same position, change the left attribute each time so that it is 30, 60, 90, 120 and 150 – that is 30*i for i=1, 2, 3, 4, 5. Break up the string where the left attribute is set and insert the expression 30*i in place of 30. (This must occur outside of our pairs of JavaScript quotes.) CSD 340 (Blum)

What looks like one long rectangle is actually five overlapping rectangles. CSD 340 (Blum)

Changing position II Instead of having each rectangle have the same vertical position, change the top attribute each time so that it is 1, 4, 9, 16 and 25 – that is i*i for i=1, 2, 3, 4, 5. Break up the string where the top attribute is set and insert the expression 30*i in place of 30. (This must occur outside of our pairs of JavaScript quotes.) CSD 340 (Blum)

CSD 340 (Blum)

Toward a color change Let us set up to make the color of each rectangle change. Insert in your loop the statement alert((17*i).toString(16)); and see its effect. (See next slide.) CSD 340 (Blum)

Use the code (17*i).toString(16) to make the hexadecimal color code 111111 for the first rectangle, 222222 for the second rectangle and so on CSD 340 (Blum)

CSD 340 (Blum)

Finishing the design Comment out the alert function statements. Change the number of iterations to 15. (I choose the numbers 15 and 17 here because 15*17 = 255 – which is corresponds FF, the highest number allowed by the usual RGB code.) CSD 340 (Blum)

The result CSD 340 (Blum)

Part 2: Tables in Tables Declare a variable to hold some HTML code To start assign it the value “<center>” Write a loop that appends the following HTML code 5 times <table cellspacing="2" cellpadding="2" border="2"><tr><td style="background-color: #6699CC"> CSD 340 (Blum)

Second Loop Next write a second loop that appends the following HTML code five times </td></tr></table> Then append </center> Final write the code to the document. CSD 340 (Blum)

Result so far CSD 340 (Blum)

Be creative Use the counting variable to alter the color code for each table data item. Adjust the number of iterations (should be the same in both loops). CSD 340 (Blum)

Odd or even if(i % 2 == 0) { Color= "FFCC99"; } else Color="99CCFF"; The condition above says divide the counting variable i by 2 and get the remainder from that division. Then ask whether that remainder is equal to 0. CSD 340 (Blum)

Stripe effect CSD 340 (Blum)