Solved

Date settings on the web

Posted on 2002-07-03
4
179 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
ID: 7129107
------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
ID: 7129924
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
ID: 7129936
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
ID: 7130335
you're welcome-- glad i could help, and thanks for the grade.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video teaches users how to migrate an existing Wordpress website to a new domain.

685 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