Hi all –
Trying to pass some strings to the whatToWrite function in the code below.
I am not receiving anything in the Firefox browser window except the stuff in <h2>
Do I need an event handler to make this work?
Seem it should work w/o EH
Thanks much
Winston
[CODE]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Lesson 2 – Looping and Functions</title>
<script langauge=”Javascript” type=”text/javascript”>
<!– Hide script from older browsers
<!– Function to write a message, text passed from scripts in the body of the document –>
function whatToWrite(message) {
document.write(message)
ducoument.write(“<br />”)
}
// End hiding script from older browsers –>
</script>
</head>
<body bgcolor=”#FFFFFF”>
<h2>
GilaMonster<br />
CIS 166AA<br />
Functions and Loops<br />
Lesson 2<br />
<hr />
</h2>
<script langauge=”Javascript” type=”text/javascript”>
<!– Hide script from older browsers
<!– For loop to write a message 5 times. Calls a function and passes a string to the function –>
document.write(<br />”)
for(i=1; i<6; i++){
whatToWrite(“An example of a for loop…”)
}
<!– While loop to write a message 5 times. Calls a function and passes a string to the function –>
document.write(<br />”)
i = 0
while (i < 6){
whatToWrite(“This is being written from a while loop…”)
i++
}
<!– Do..While loop to write a message 5 times. Calls a function and passes a string to the function –>
document.write(<br />”)
i = 0
do {
whatToWrite(“Finally, an example of a Do..While loop…”)
i++
}
while(i < 6)
// End hiding scripr from older browsers –>
</script>
</body>
</html>