Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 82 - 2609_Logicode
P. 82

    SOME MORE PROGRAMS

                         Code      Create  a web page  that  checks  whether a person is eligible  to  vote  based  on
                           9       their age.

                      <!DOCTYPE HTML>
                      <HTML>

                      <HEAD>                                                    Create a simple web page using HTML,
                                                                               CSS and JavaScript to display a greeting
                      <TITLE>VOTE ELIGIBILITY</TITLE>
                                                                                   message when a button is clicked.
                      </HEAD><BODY>
                      <SCRIPT>
                      var age = prompt("Enter your age:");

                      if (age >= 18) {

                      document.write("<H2>You are eligible to vote! </H2>");
                      }
                      else {

                      document.write("<H2>You are not eligible to vote. </H2>");
                      }

                      </SCRIPT>
                      </BODY>

                      </HTML>
                      The output of the preceding HTML code is as follows:

                       80   Premium Edition-VIII

| 77 78 79 80 81 82 83 84 85 86 87 |