SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Addict WebMasterAJ's Avatar
    Join Date
    Aug 2000
    Location
    Miami
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am wondering as to where I can find a Java Script that shows text during a certain group of days. For example, if I wanted to show "Miami Dolphins vs. Tampa Bay" during 12-07-00 thru 12-12-00.

    I am guessing that this would be pretty easy if its not done already, but I HAVE no clue about Java Script.

    Any help is appreciated.

    Thanks
    Andrew Tatum
    FinHeaven & Co - Get Drenched With Finformation
    The FinHeaven & Co Forums

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2000
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here ya go. Add your teams and dates to your choices. (note found this at another forum months ago, so can't take credit for it)


    Put this where you want it located in your page:

    <SCRIPT LANGUAGE="JavaScript">
    function showGame(beginDateString,endDateString) {

    var beginDate_dt;
    var endDate_dt;
    var beginDate;
    var endDate;
    var now;
    var today;

    beginDate_dt = new Date(beginDateString);
    endDate_dt = new Date(endDateString);

    now = new Date();
    today = new Date(now.getYear(),now.getMonth(),now.getDate());

    beginDate = new Date(beginDate_dt.getYear(),
    beginDate_dt.getMonth(),
    beginDate_dt.getDate());

    endDate = new Date(endDate_dt.getYear(),
    endDate_dt.getMonth(),
    endDate_dt.getDate());

    if ((endDate >= today) && (beginDate <= today))
    {
    return true;
    }
    else {
    return false;
    }
    }

    // first quotes are start date of time period and
    // second quotes are end date of time period
    // dates cannot overlap or you will get mixed results
    // html can be included inside of the document.writeln('') but no single quotes are allowed

    if (showGame("10/11/2000","10/10/2000")) {
    document.writeln('Upcoming Game: Green Bay vs. Tampa Bay');
    }
    else if (showGame("10/11/2000","10/13/2000")) {
    document.writeln('Upcoming Game: Chicago vs. Tampa Bay');
    }
    else if (showGame("01/16/2000","01/22/2000")) {
    document.writeln('Upcoming Game: Atlanta vs. Tampa Bay');
    }
    else if (showGame("01/23/2000","10/30/2000")) {
    document.writeln('Upcoming Game: St. Louis vs. Tampa Bay');
    }
    else {
    document.writeln('No Games are Scheduled any time soon!');
    }
    </SCRIPT>

    <Edited by brewskee on 12-09-2000 at 01:51 AM>

  3. #3
    SitePoint Addict WebMasterAJ's Avatar
    Join Date
    Aug 2000
    Location
    Miami
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks man!

    You might not be able to take credit for the script, but thanks for looking it up.

    Andrew Tatum
    FinHeaven & Co - Get Drenched With Finformation
    The FinHeaven & Co Forums

  4. #4
    Sports Publisher mjames's Avatar
    Join Date
    Jan 2000
    Location
    Charlotte, NC
    Posts
    5,891
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This sounds like a good idea, but keep in mind many users who have JavaScript disabled won't be able to see it. Might be better to update it manually?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •