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

Example 6.3:
If Statements with Boolean Variables


Click on the buttons to set the status of the bStatus variable, and to display the Alert box showing you the status:


This is the script we used: <SCRIPT LANGUAGE="JavaScript"> <!-- var bStatus = true function CheckStatus() { if (bStatus) { alert("The value in bStatus is true") } else { alert("The value in bStatus is false") } } //--> </SCRIPT> </HEAD> <BODY> <BR> <form> <input type="button" value="True" onclick="bStatus = true; CheckStatus()"> <input type="button" value="False" onclick="bStatus = false; CheckStatus()"> </form>
Previous Example-|-Next Example-|-Return to Chapter Listing