7
Javascript- Functions A function is a group of reusable code which can be called anywhere in your program. This stops the need of writing the same code again and again.

Loops

Embed Size (px)

DESCRIPTION

ohihnm

Citation preview

Page 1: Loops

Javascript- Functions

A function is a group of reusable code which can be called anywhere in your program. This stops the need of writing the

same code again and again.

Page 2: Loops

Copy the following code into dreamweaver

<head> <script type="text/javascript">

function sayHello() {

alert("Hello World")

}

</script>

</head>

<body>

<input type="button" onclick="sayHello()" value="Say Hello" />

</body>

Page 3: Loops

When you click on the link, it presents an alert box

Page 4: Loops

Click inside the input type and press spacebar on your keyboard, a selection should appear,

choose onmouseover.

Page 5: Loops

Click inside the input type and press spacebar on your keyboard, a selection should appear,

choose onmouseover.

Page 6: Loops

Enter the following=>

onmouseover=alert("hello")

*click on liveview at the top of dreamweaver and see what happens.

Page 7: Loops

Javascript: for Loop

the for loop makes a list of code copy over and over.

Open a new html page and copy the following into the body tag-

<script type="text/javascript">

var bodyslam= prompt("enter a number");

bodyslam= parseFloat(bodyslam);

if (bodyslam>= 200){

for(bodyslam=5;bodyslam<=5000000;bodyslam=bodyslam+30)

document.write("<PRE>hello </PRE> ");

}

else {

alert("not a high enough number, sorry")

} </script>

The value to enter

How many times it repeats