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

Example 6.6:
Using "Not Equal To" (!=)


This time we are checking to see if the sButton variable does not contain the value A:


This is the script we used: <SCRIPT LANGUAGE="JavaScript"> <!-- var sButton function function1() { if (sButton != "A") { alert("The variable is not equal to \'A\' \n It is \'" + sButton + "\'") } } //--> </SCRIPT> </HEAD> <BODY> <BR> <form> <input type="button" value=" Button A " onclick="sButton = 'A'; IfExample()"> <input type="button" value=" Button B " onclick="sButton = 'B'; IfExample()"> <input type="button" value=" Button C " onclick="sButton = 'C'; function1()"> </form>
Previous Example-|-Next Example-|-Return to Chapter Listing