Click to See Complete Forum and Search --> : lol help!


Calmaris
03-21-2003, 09:16 AM
Ok I'm just starting javascripting and going straight from my new book! I get an error in the if statement saying object expected. What object? Thx

<script language="javaScript">
<!--
If (confirm("Do you want to know the time?"));
{
display()
}

function display() {
var now = new Date()
var hours = now.getHours()
var Minutes = now.getMinutes()
var Seconds = now.getSeconds()
var current_Time = hours + ":" + Minutes + ":" + Seconds
alert(" Time is:" + current_Time)
}


//-->
</script>

pyro
03-21-2003, 09:20 AM
Two typos, both in the first line:

If (confirm("Do you want to know the time?"));

should be:

if (confirm("Do you want to know the time?"))

You had a capital I in your if statement, and you ended it with a ; if statements are not ended with a ;

Cheers...