Deeply Nested if. . .else Constructions : If : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » If »

 

Deeply Nested if. . .else Constructions



<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function testLetter(form){
    inpVal = form.entry.value; 
    if (inpVal != "") {
        if (inpVal == "A") {
            alert("Thanks for the A.");
        else if (inpVal == "B") {
            alert("Thanks for the B.");
        else if (inpVal == "C") {
            alert("Thanks for the C.");
        else {          
            alert("Sorry, wrong letter or case.")
        }
    else {   
        alert("You did not enter anything.")
    }
}
</SCRIPT>
</HEAD>
<BODY>
<FORM>
Please enter A, B, or C and press Enter key:
<INPUT TYPE="text" NAME="entry" onChange="testLetter(this.form)">
</FORM>
</BODY>
</HTML>

           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Language Basics
» If