follow up Question for jsmckenzie: Date settings on the web Date: 07/03/2002

This is a follow-up question for jsmckenzie regarding Question: Date settings on the web  Date: 07/03/2002 10:30AM PST      

I forgot to ask this:

After the day of the week and sign are found  (”You were born on a Friday and you are a Gemini”)

What I forgot to ask is I need to have a page loaded for each sign, example:  If the sign is Gemini then the
Gemini page would load giving the horoscope for that sign and so forth for each of the signs in the sodiac.

The way it is now is one page (page2.htm) loads for any sign.  This won’t work becuase each sign is different
and needs it’s own page.  The other advantage is I can edit each page to suit my needs.  Also, these pages are
going to be a general statement of the sign and do not have to modified for each day or week , so I just need a
page for each individual sign. Thanks fo the help.
charliebccAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
jsmckenzieConnect With a Mentor Commented:
I've changed it a little so that you only need page1.htm:

************************ Page1.htm **********************

<html>
 <head>
    <title>page1.htm</title>
    <script language="javascript">
       var sQuery = location.search;
       var bSubmitted = sQuery.indexOf('submitted=1')!=-1
       if(bSubmitted)
          {
          afterSubmit()
          }
       
       function afterSubmit()
          {          
          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);
          location.replace(sSign + '.htm?day=' + sDayArray[oDate.getDay()])

          }

       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="page1.htm">
       <input type="hidden" name="submitted" value="1">
       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>

**********************************************************


******************** capricorn.htm ***********************

<html>
   <head>
      <title>capricorn.htm</title>
      <script language="javascript">
         var sQuery = location.search;
         var iDayPos = sQuery.indexOf('day=') + 4
         var sDay = sQuery.substring(iDayPos, sQuery.length);
         function writeResult()
          {
          document.write('You were born on a ');
          document.write(sDay);
          document.write(' and you are a Capricorn.')
          }
      </script>
   </head>
   <body>
      <script language="javascript">
         writeResult();
       </script>
   </body>
</html>

**********************************************************

Let me know if you have problems.
0
 
jsmckenzieCommented:
I don't have the code in front of me, but you could change page2.htm to redirect to a third page.  The last line of the javascript on page2.htm could be something like:

location.href = sSign + '.htm';

0
 
charliebccAuthor Commented:
Sorry, that's a little vague for my limited knowledge.  I need more directions.  Thanks.  I can wait for the code if you have it. This way I will be sure of what I am doing.

0
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
jsmckenzieCommented:
can you post the code again?  I don't have it with me here.
0
 
charliebccAuthor Commented:
Here it is:

Page 1

<html>
  <head>
     <title>page1.html</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.html">
        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>


Page 2 ****************************************************

<html>
  <head>
     <title>page2.html</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
 
charliebccAuthor Commented:
I inserted the code

location.href = sSign + '.htm';

as you stated and it works.  The only problem, and it is a minor one, is that the original statement "You were born on a 'day' and you are a 'sign'." is hidden by the new ".htm" page that comes up as requested.  Is there a way to pause the first page (page2.htm) or have the original information "You were born on a 'day' and you are a 'sign'." come up on the second page.  I hope this is clear.  
0
 
charliebccAuthor Commented:
It works great!  Thanks so much for your help.

Charlie
0
 
charliebccAuthor Commented:
Thanks again.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.