Solved

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

Posted on 2002-07-11
8
247 Views
Last Modified: 2013-12-25
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.
0
Comment
Question by:charliebcc
  • 5
  • 3
8 Comments
 
LVL 2

Expert Comment

by:jsmckenzie
ID: 7147755
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
 

Author Comment

by:charliebcc
ID: 7149373
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
 
LVL 2

Expert Comment

by:jsmckenzie
ID: 7149484
can you post the code again?  I don't have it with me here.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:charliebcc
ID: 7150405
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
 

Author Comment

by:charliebcc
ID: 7152113
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
 
LVL 2

Accepted Solution

by:
jsmckenzie earned 100 total points
ID: 7155536
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
 

Author Comment

by:charliebcc
ID: 7160115
It works great!  Thanks so much for your help.

Charlie
0
 

Author Comment

by:charliebcc
ID: 7160118
Thanks again.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
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.

770 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