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

Example 6.11:
Boolean "Not"


Click on the button to see the value in bStatus. If bStatus does not equal true, the first alert box is displayed:
This seems to be the same as Example 6-3, but we've created the if statement differently, using a Boolean Not operator (!).

This is the script we used. First, this in the HEAD: <SCRIPT LANGUAGE="JAVASCRIPT"> <!-- var bStatus = true function CheckStatus() { if (!bStatus) { alert("The value in bStatus is false") } else { alert("The value in bStatus is true") } } //--> </SCRIPT> Then these buttons: <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