Solved

Date settings on the web

Posted on 2002-07-03
4
180 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

739 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