There are many Cat Age Calculators on the web these days but I developed this one in Active Server Pages which converts a cat's actual years to people years. Many of us have an unusual affinity for our pets, and this is a way of making us feel better that they are actual human beings inside. I also programmed a Dog Age Calculator which is beneath the Cat Age Calculator code, for those of us with a canine in mind.
The first ASP page has two text boxes, one for our cat's or dog's name, and the other for their actual years. You can put actual names and years as the default values which I have, and have other people change them accordingly. The background and pictures of course are totally up to you - I put the sound of a cat's meow on mine. These are great things to develop for kids and small students, and someday (maybe sooner or later), they may actually understand that VBScript!
For an example, please go to http://www.juliagreen.com/cat.asp Here is the code for all 3 pages.... <html>
<head> <STYLE TYPE="text/css"> img { border: 10px double #E6D1B3 ) <BR> </STYLE> <TITLE>Cat Age Calculator</TITLE> <bgsound src="images/meow.wav" loop="2">
</head>
<body background="images/catsbg1.gif">
<H1 align="center"><font color="#800080">Julie's Cat Age Calculator</font></h1>
<center> <img src="images/cat.jpg" width="400" height="300"> <h3><font color="#800080">A cat is considered to be senior when they are 8 to 10 years of age. Cat's over 12 years of age are considered geriatric. Phoenix, my house cat, is 12 years old.</font></h3> <p><h3> <font color="#800080"> To all those cats out there!, The longest a cat has ever lived is 34 years.</font></h3><p>
<form action="cat2.asp" method="post"> <b> <font color="#800080"> What is the name of your cat?<p> <input type="text" name="name" size="10" value="Phoenix"><p> What is the age of your cat in real years?<p> <input type="text" name="age" size="10" value="12"> years</font> <P> <input type="submit"><input type="reset"> </center> </form> <a href="dog.asp"><b><h2 align="center"><font color="#800080">Go to Dog Age Calculator!!</font></b></a></h2>
</html> |
Cat 2, the processing page
<%Option Explicit%>
<html>
<head> <STYLE TYPE="text/css"> img { border: 10px double #E6D1B3 ) <BR> </STYLE> <title>CAT AGE CALCULATOR ANSWER</title> <bgsound src="images/meow.wav" loop="1">
</head>
<body background="images/catsbg1.gif">
<h1 align="center"><font color="#9900CC">CAT AGE CALCULATOR ANSWER</font></h1> <center> <img src="images/tiger1s.jpg" border="4"> </center>
<%
Dim age2, age3, varAge, varName
varAge=Request.Form("age") varName=Request.Form("name")
If varAge = 1 Then age2=15 End If If (varAge > 1) Then age2=(varAge*5) + 10 End If If varAge = 7 Then age2=45 End If If (varAge > 7) Then age2=(varAge*4) + 17 End If If varAge=10 Then age2=58 End If If (varAge > 10) Then age2=(varAge*5)+8 End If If varAge=15 Then age2=78 End If If (varAge>15) Then age2=(varAge*4)+18 End If If varAge=20 Then age2=98 End If If varAge > 20 Then Response.Write "<br><center><h1>You're over 100 kitty!</h1></center>" End If
Response.Write "<center><b><i><font size=+2><font color=#9900CC>" & varName Response.Write "<b><i><font size=+2><font color=#9900CC>'s people age is " Response.Write "<b><i><font size=+2><font color=#9900CC>" & age2 Response.Write "<b><i><font size=+2><font color=#9900CC> years." Response.Write "</center>"
%> <p><p> <center> <img src="images/kitty.jpg" height="248"><p> <a href="cat.asp"><b><i><font size="4">Go back to Cat Calculator!!</font></i></b></a> </html>
|
The DOG AGE CALCULATOR
The same technique is used, an ASP page with a name and age textbox. I've just put the resulting asp code here, instead of the originating page. For an example, go to www.juliagreen.com/dog.asp.
<%Option Explicit%> <html> <head> <STYLE TYPE="text/css"> img { border: 10px double #800000 ) <BR> </STYLE> <title>DOG AGE CALCULATOR ANSWER</title> </head> <body bgcolor="#800000" text="#FFFFFF" background="images/pawsback.jpg">
<h1 align="center"><font color="#800000">DOG AGE CALCULATOR ANSWER</font></h1> <font color="#800000"> <center> <img src="images/dogsad.jpg"> </center>
<%
Dim age2, age3, varAge, varName
varAge=Request.Form("age") varName=Request.Form("name") If varAge = 1 Then age2=15 End If If varAge = 2 Then age2=24 End If If varAge > 2 Then age2=15+(varAge*4) End If If varAge=21 Then Response.Write "<b><i><font size=+2><font color=#800000>" & varName Response.Write "<b><i><font size=+2><font color=#800000>! You're one year short of a 100! " Response.Write "<b><i><font size=+2><font color=#800000>That's a doggone long time!" End If If varAge>21 Then Response.Write "<b><i><font size=+2><font color=#800000>" & varName Response.Write "<b><i><font size=+2><font color=#800000>! Guess what, you're a Centurion! " End If
Response.Write "<br><br><b><i><font size=+2><font color=#800000>" & varName Response.Write "<b><i><font size=+2><font color=#800000>'s people age is " Response.Write "<b><i><font size=+2><font color=#800000>" & age2 Response.Write "<b><i><font size=+2><font color=#800000> years."
%> </font> <p><p align="center"> <a href="dog.asp"><b><h2 align="center"><font color="#800000">Go back to Dog Calculator!!</font></b></a></h2> <p align="center"><p align="center"> <a href="cat.asp"><b><h2 align="center"><font color="#800000">Go back to Cat Calculator!!</font></b></a></h2>
</html>
-->
|
|
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More ASP Code Articles More By aspfree developerWorks - FREE Tools! | The IBM DB2 Deep Compression ROI tool is designed for DBA’s and IT management personnel to perform a clinical analysis of the cost savings gained from the Storage Optimization feature of DB2 9 for Linux, UNIX and Windows. The feature, also known as Deep Compression, compresses data that lies within a database by up to 80% at times. FREE! Go There Now!
| | | | IBM Enterprise Modernization solutions help organizations evolve core IT systems towards modern architectures and technologies—reducing the burden of maintenance and freeing up resources to develop new business requirements and capabilities. With the IBM Enterprise Modernization Sandbox for System z you can evaluate IBM Enterprise Modernization solutions focused on five key areas: Assets, Architectures, Skills, Processes and Infrastructures, and Investment. Each solution is based upon real customer experiences and offers a proven path to get you started with your modernization projects. FREE! Go There Now!
| | | | As systems increase in complexity, communication between systems and software teams becomes more and more difficult. Now, there’s a way to improve product quality and communication.<br />Read the “Model Driven Systems Development” white paper to see how. Also included in this kit are more educational white papers, customer examples, tutorials, informative Webcasts, and best practices for designing, building and managing systems.<br /> FREE! Go There Now!
| | | | Learn how Rational Build Forge can extend a simple compile and package build process by adding customization and deployment capability. Go from a manual method to automating: checking for code changes; getting the latest source; compiling and packaging; customizing; copying to and restarting a deployment server; and sending e-mail notification that a new version is available. FREE! Go There Now!
| | | | This whitepaper provides areas to consider when evaluating any software configuration management solution. It addresses how the IBM solutions (Rational ClearCase and Rational ClearQuest) meet the needs and requirements of both project leaders and developers to provide successful Software Change and Configuration Management. FREE! Go There Now!
| | | | This paper is about the critical role that a discipline called integrated requirements management can play in helping to ensure that your business goals and IT investments are continuously aligned—whether you are sourcing, integrating, building or maintaining software. It also looks at ways that automated IBM Rational® products can work together to help you use requirements in the very best way. FREE! Go There Now!
| | | | Attend this launch webcast with Scott Hebner, Vice President of IBM Rational Marketing and Strategy, where he will overview Rational’s new offerings and programs to help customers accelerate software innovation on System z. He will discuss how these solutions help organizations extend their core business processes toward modern architectures such as SOA and web technologies to deliver business improvements that stand the test of time. FREE! Go There Now!
| | | | In this webcast, IBM Rational will discuss the importance of Web application security and will share techniques and best practices to introduce application security testing into current QA processes including: understanding common security vulnerabilities and techniques to integrate security testing with defect tracking and remediation systems in an effort to safeguard sensitive online information. FREE! Go There Now!
| | | | IBM Lotus Notes 8 provides a wide range of developers the ability to provide customized, integrated user interfaces via composite applications and via custom sidebar and toolbar plug-ins. This webcast provides you with tips and techniques to use with out-of-the-box capabilities of Lotus Notes 8, and survey how you can share useful components within your own company and within a larger community. FREE! Go There Now!
| | | | With IBM Rational Systems Development Solution, you can deliver products faster with higher quality. Within this kit, Read the “Model Driven Systems Development” white paper to see how to improve product quality and communication. Then check out the rest of the e-Kit to learn more about important topics that can affect the success of any software project through customer examples, tutorials, informative Webcasts, and best practices for designing, building and managing systems. From start to finish, at every stage in your projects, Rational Systems Development Solution can help your company reach its full potential. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |