10 questions, 10 min
Wednesday, December 29, 2010
Tuesday, December 28, 2010
Worked on my website and waiting for my 46" 3d TV
Monday, December 20, 2010
Some links to my exercises
Move the mouse over the pictures see what will happen.
move the mouse over to change the person shown.
calculator
XMAS and Snowman
Alert box
try the loop.
Monday, December 13, 2010
Everything going well
Tuesday, December 7, 2010
In JavaScript, there are two different kind of loops:
while - loops through a block of code while a specified condition is true
for - loops through a block of code a specified number of times
The while Loop
The while loop loops through a block of code while a specified condition is true.
Example of while loop:-
<script type="text/javascript">
var i=0;
while (i<=5) { document.write("The number is " + i);
document.write("<br />");
i++;
}
</script>
Explanation:
i is equal to 0.
While i is less than , or equal to, 5, the loop will continue to run.
i will increase by 1 each time the loop runs.
try the loop.
Thursday, December 2, 2010
The If Statement
if statement
if...else statement
use this statement to execute some code if the condition is true and another code if the condition is false
if...else if....else statement
use this statement to select one of many blocks of code to be executed
switch statement
use this statement to select one of many blocks of code to be executed
Using the If Statement
Try this in your page
<script type="text/javascript">
var d = new Date()
var time = d.getHours()
if (time<10)>Good morning");
}
else if (time>10 && time<16)>Good day");
}
else
{
document.write("Hello World!");
}
</script>
Prompt Box
<html>
<head>
<script type="text/javascript">
function show_prompt()
{
var name=window.prompt("Please enter your name","Harry Potter");
if (name!=null && name!="")
{
document.write("Hello " + name + "! How are you today?");
}}
</script>
</head>
<body>
<input type="button" onclick="show_prompt()" value="Show prompt box" />
</body>
</html>
Check the prompt box on top of the page on the right.