Solved

Date settings on the web

Posted on 2002-07-03
4
182 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

729 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