This Web page prompts visitors for their age. Once the age is entered, it is sent to a JavaScript function located in the head of the Web page. If the age is less than sixteen, the function creates a response appropriate for that age. The response is displayed below:
Welcome!Here's the code used to create the function in the head section of the Web page:
<script language="Javascript" type="text/javascript">Here's the code used to prompt users for their age (located in the body of the document):
<script language="Javascript" type="text/javascript">| comparison operators | |
|---|---|
| == | is equal |
| != | is different |
| < | is less than |
| <= | is less than or equal |
| >= | is equal or greater than |
| > | is greater than |