Previous Example-|-Next Example-|-Return to Chapter Listing

Example 6.7:
The "Greater Than" Operator (>)


The button calls function1(), which uses the Greater Than operator in an if statement to determine how many seconds have passed since the start of the current minute, and so which message should be displayed.:


This is the script we used: <SCRIPT LANGUAGE="JavaScript"> <!-- function function1() { var dToday = new Date() var nSeconds = dToday.getSeconds() if (nSeconds > 30) { alert("We are MORE than halfway through this minute. Seconds=" + nSeconds ) } else { alert("We are LESS than halfway through this minute. Seconds=" + nSeconds ) } } //--> </SCRIPT> </HEAD> <BODY> <BR> <form> <input type="button" value=" Button A " onclick="function1()"> </form>
Previous Example-|-Next Example-|-Return to Chapter Listing