Creating a dynamic page with random photos - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Creating a dynamic page with random photos

Description:

... page with random photos. Madeline Ortiz-Rodr guez. September ... If you need to use quotations again, use apostrophes instead of quotation marks. For example: ... – PowerPoint PPT presentation

Number of Views:74
Avg rating:3.0/5.0
Slides: 10
Provided by: madelineor
Category:

less

Transcript and Presenter's Notes

Title: Creating a dynamic page with random photos


1
Creating a dynamic page with random photos
  • Madeline Ortiz-Rodríguez
  • September 8, 2003

2
Objectives
  • To create a simple web page with JavaScript code
    in Dreamweaver, so that pictures are presented
    randomly.
  • Example
  • http//plaza.ufl.edu/mortizro/DimeLesson/photo.htm
    l

3
JavaScript
  • JavaScript is not the same as Java.
  • The code is included where you want an action to
    appear in the web page.
  • In JavaScript you start counting with the number
    zero (0).
  • JavaScript is case sensitive.
  • Be careful with spaces and quotation marks.

4
Random photos code
var num Math.round(1 Math.random()) var
photonum if (photo0) document.write("ltimg
src'photo1.jpg' width200 height150gt") else
if (photo1) document.write("ltimg
src'photo2.jpg' width200 height150gt")
5
Math.random( )
  • Random numbers in JavaScript run from .000 to
    .999
  • There are one thousand random numbers in
    JavaScript.
  • To find random numbers we multiple by an integer.
    For example
  • 1 Math.random()

6
Math.round( )
  • Rounding a random number will convert it into an
    integer (a whole number).
  • For example
  • 0.499 0
  • O.525 1
  • 2.709 3
  • The instruction Math.round(1 Math.random())
  • Will provide two random numbers 0 and 1

7
Document.write( )
  • Code that allows to place text or images on the
    screen.
  • Inside the quotation marks you write HTML codes.
  • If you need to use quotations again, use
    apostrophes instead of quotation marks. For
    example
  • document.write(ltimg src'photo1.jpg'gt)

8
Changing the code
  • Number of photos
  • Adding extra code

9
References
Burns, Joe. (1999).  JavaScript Goodies. IN QUE.
Lesson 33 Creating Random Numbers Through
Mathematics Burns, J. Growney, A. The
JavaScript Primers 30 Steps that make
JavaScripting fun to learn! http//www.htmlgoodies
.com/primers/jsp/ The JavaScript Source.
http//javascript.internet.com/
Write a Comment
User Comments (0)
About PowerShow.com