Solved

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

Posted on 2002-07-11
8
237 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
 

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

707 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now