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! | Build secure Web services with transport-level security using IBM Rational Application Developer V7 and IBM WebSphere Application Server V6.1. Follow this three-part series for step-by-step instructions about how to develop Web services and clients, configure HTTP basic authentication, and configure HTTP over SSL (HTTPS). This first part of the series walks you through building a Web service for a simple calculator application. You generate and test two different types of Web services clients: a Java Platform, Enterprise Edition (Java EE) client and a stand-alone Java client. You also handle user-defined exceptions in Web services. FREE! Go There Now!
| | | | WebSphere Process Server delivers a unique integration framework that simplifies existing IT resources. Often, as IT assets grow to support business demand, so too does their complexity and manageability. In this webcast, we’ll discuss how WebSphere Process Server helps deliver an SOA infrastructure that provides a common model to orchestrate, mediate, connect, map, and execute the underlying IT functions. Discover how WebSphere Process Server simplifies integration of business processes by leveraging existing IT assets as reusable services without the complexities of traditional integration methodologies. FREE! Go There Now!
| | | | Visit IBM developerWorks to download a free trial of the latest release of IBM Lotus Sametime Standard V8.0. Lotus Sametime Standard V8.0 is a platform for unified communications and collaboration that combines security features with an extensible, open solution including integrated Voice over IP, geographic location awareness, mobile clients, and a robust Business Partner community offering telephony and video integration. FREE! Go There Now!
| | | | Visit IBM developerWorks to download a free trial version of WebSphere Extended Deployment Compute Grid, which lets you schedule, execute, and monitor batch jobs. Because online transaction processing and batch jobs execute simultaneously on the same server resources, you can avoid costly duplication of resources. Compute Grid supports job types of Java transactional batch, compute-intensive and a new type called "native execution", which enables non-Java workloads to run on distributed end points. FREE! Go There Now!
| | | | Ken Krugler, co-founder of code search company Krugle, and Laura Merling, vice president of Marketing and Business Development for Krugle, join to talk about the ins and outs of code search and what it means as a new feature for developerWorks users. FREE! Go There Now!
| | | | Join this Rational Talks to You teleconference on November 29 at 1:00 pm ET to participate in an interactive discusssion with Grady Booch around architecture and reuse. Get your questions answered! FREE! Go There Now!
| | | | Get a free trial download of the latest version of IBM Rational Performance Tester V7.0.1, a load and performance testing solution for teams concerned about the scalability of their Web-based applications. Combining multiple ease-of-use features with granular detail, Rational Performance Tester simplifies the test-creation, load-generation and data-collection processes that help teams ensure the ability of their applications to accommodate required user loads. FREE! Go There Now!
| | | | Get a free trial download of the latest version of IBM Rational Tester for SOA Quality V7.0.1, a functional and regression testing tool that enables the creation, comprehension, modification and execution of testing GUI-less Web services. FREE! Go There Now!
| | | | Visit IBM developerWorks to try the IBM SOA Sandbox for people. The SOA Sandbox for people provides a trial environment with the necessary tooling and components required to enable consistent human and process interaction and collaboration, showing how you can improve user experience and business productivity. FREE! Go There Now!
| | | | Viper 2 brings a great value to developer communities including SQL, XML, PHP, Ruby, .NET and Java. You probably already know that DB2 Express-C is free for developers to develop, deploy and distribute. Viper 2 provides a variety of means that help move your application from the development stage to deployment more rapidly. This webcast shows how to best utilize the latest tools available for developing DB2 applications. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |