Solved

Date settings on the web

Posted on 2002-07-03
4
175 Views
Last Modified: 2013-12-25
I am building a horoscope website and I would like to have users type in their date of birth and have a page appear that tells them what day they were born on and what there astrological sign is.  Example: they type in 3/11/48 and they get a page that tells them:

   "YOU ARE A PISCES AND YOU WERE BORN ON THURSDAY"
or
   "YOU WERE BORN ON THURSDAY AND YOU ARE A PISCES"

Is there any kind of scripts out there that can do this?

Thanks for the help.

Charlie

 
0
Comment
Question by:charliebcc
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
jsmckenzie earned 400 total points
Comment Utility
------page1.htm--------------------------------
<html>
   <head>
      <title>page1.htm</title>
      <script language="javascript">
         function generateOptions(sName,iNum)
            {
            document.write('<select name="' + sName + '">');
            for(var i=1; i<=iNum; i++)
               {
               document.write('<option value="' + i + '">' + i + '</option>');
               }
            document.write('</select>');
            }
      </script>
   </head>
   <body>
      <form name="frmScope" method="get" action="page2.htm">
         Enter Your Birthday:
         <br>
         <script language="javascript">
            document.write('Month:');
            generateOptions('cboMonth',12);
            document.write('<br>Day:');
            generateOptions('cboDay',31);
         </script>
         <br>
         Year: <input type="text" name="txtYear" maxlength="4" size="4" value="1900">
         <br><br>
         <input type="button" value="Submit" onClick="frmScope.submit()">
      </form>
   </body>
</html>

------page2.htm--------------------------------
<html>
   <head>
      <title>page2.htm</title>
      <script language="javascript">
         var sQuery = location.search;
         var iYearPos = sQuery.indexOf('txtYear=') + 8
         var iDayPos = sQuery.indexOf('cboDay=') + 7
         var iMonthPos = sQuery.indexOf('cboMonth=') + 9
         var iYear = sQuery.substring(iYearPos, sQuery.length);
         var iDay = parseInt(sQuery.substring(iDayPos, iDayPos + 2));
         var iMonth = parseInt(sQuery.substring(iMonthPos, iMonthPos + 2));
         var sSign='';
         
         switch(iMonth)
            {
            case 1: iDay <=19 ? sSign = 'Capricorn' : sSign = 'Aquarius'; break;
            case 2: iDay <= 18 ? sSign = 'Aquarius' : sSign = 'Pisces'; break;
            case 3: iDay <= 20 ? sSign = 'Pisces' : sSign = 'Aries'; break;
            case 4: iDay <= 19 ? sSign = 'Aries' : sSign = 'Taurus'; break;
            case 5: iDay <= 20 ? sSign = 'Taurus' : sSign = 'Gemini'; break;
            case 6: iDay <= 21 ? sSign = 'Gemini' : sSign = 'Cancer'; break;
            case 7: iDay <= 22 ? sSign = 'Cancer' : sSign = 'Leo'; break;
            case 8: iDay <= 22 ? sSign = 'Leo' : sSign = 'Virgo'; break;
            case 9: iDay <= 22 ? sSign = 'Virgo' : sSign = 'Libra'; break;
            case 10: iDay <= 22 ? sSign = 'Libra' : sSign = 'Scorpio'; break;
            case 11: iDay <= 21 ? sSign = 'Scorpio' : sSign = 'Sagittarius'; break;
            case 12: iDay <= 21 ? sSign = 'Sagittarius' : sSign = 'Capricorn'; break;
            }

         var sDayArray = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
         var sMonthArray = ['','January','February', 'March','April','May','June','July','August','September','October','November','December'];
         
         var oDate = new Date(iDay + ' ' + sMonthArray[iMonth] + ', ' + iYear);

         function writeResult()
            {
            document.write('You were born on a ');
            document.write(sDayArray[oDate.getDay()]);
            document.write(' and you are a');
            if(sSign=='Aquarius' || sSign=='Aries') document.write('n');
            document.write(' ' + sSign + '.');
            }

      </script>
   </head>
   <body>
      <script language="javascript">
         writeResult();
      </script>
   </body>
</html>
0
 

Author Comment

by:charliebcc
Comment Utility
I copied each page designation into separate html pages using notepad.  Meaning "Page1" information went into an html page called page1.html and the same with the "page2" information.  When I launch the first page everything comes up fine.  I enter the date information and hit the submit button and I get a message saying "The page cannot be displayed." Any suggestions?  Should page2 have a different name? Awaiting you most valued help.

Charlie

0
 

Author Comment

by:charliebcc
Comment Utility
I found my error.   I had page2 named page2.html instead of page2.htm.  I changed the name ofthe page and it works great.  I doubled the points to show my appreciation on what a great job you did.  Thanks so very much.  And keep up the great work!

Charlie
0
 
LVL 2

Expert Comment

by:jsmckenzie
Comment Utility
you're welcome-- glad i could help, and thanks for the grade.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now