Our website is made possible by displaying online advertisements to our visitors.
Please consider supporting us by disabling your ad blocker.
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Anyone know Javascript?

  1. #1
    Jiggles's Avatar
    Join Date
    Mar 2006
    Location
    Edinburgh, Scotland.
    Age
    32
    Posts
    8,327

    Default Anyone know Javascript?

    I keep getting an error with this script:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <head>
    <title>Station Activity</title>

    <style type="text/css">
    td { font-size:0.6em; } /* temporary for testing purposes */
    #NowOn {
    border: 2px solid red;
    font-size: 1.5em;
    color: red;
    background: yellow;
    height: 200px;
    width: 400px;
    }
    </style>

    <script type="text/javascript">

    /* NOT CURRENTLY USED
    var thedate = new Date();
    var dayofweek = thedate.getDay();
    var hourofday = thedate.getHours();

    var GMT = new Date().getTimezoneOffset();
    var offsetGMT = -5 * new Date().getTimezoneOffset()/60;
    */

    // Sun=0 1 2 3 4 5 Sat=6
    var DayOfWeek = new Array('Weekend','Monday','Tuesday','Wednesday','Th ursday','Friday','Weekend');

    var NoShow = 'No Show Scheduled<br />for KSWH';
    var DH = new Array (7);
    for (d=0; d<7; d++) {
    DH[d] = new Array (24);
    for (h=0; h<24; h++) { DH[d][h] = ''; }
    }

    <?php include ('times.html') ?>
    // Add more when schedule is known. Note: there may be better ways to do this when information is known.

    function NowON() {
    var thedate = new Date();
    var dayofweek = thedate.getDay();
    var hourofday = thedate.getHours();
    var showOn = DH[dayofweek][hourofday];
    if (showOn == '') { showOn = '<p />No Show Currently Scheduled for KSWH'; }
    document.getElementById('NowOn').innerHTML = showOn;
    }
    </script>
    </head>
    <body>
    <div id='NowOn'><script type="text/javascript"> document.write(NowON())</script></div>
    </body>
    </html>
    It works but it keeps adding "undefined" to the end of the out put.

    the PHP include content is:
    DH[1][10] = 'No Show Name<br>with Cody Graves<br>Monday at 10 AM<hr>No Genre';
    DH[1][12] = 'No Show Name<br>with DJ JT<br>Monday at Noon<hr>No Genre';
    DH[1][14] = 'Real Talk<br>with DJ Yella<br>Monday at 2 PM<br>No Genre';
    DH[1][16] = 'No Show Name<br>with Katy Cox<br>Monday at 4 PM<br>Rap';
    DH[1][17] = 'The Greatest<br>with DJ Fresh<br>Monday at 5 PM<br>No Genre';
    DH[1][18] = 'Revolution Corner<br>with Randy Underwood<br>Monday at 6 PM<br>No Genre';
    DH[1][20] = 'Daily Affirmation<br>with DJ Hightower<br>Monday at 8 PM<br>No Genre';
    DH[1][22] = 'No Show Name<br>with David Doggett<br>Monday 10 to Midnight<br>No Genre';
    DH[1][23] = 'No Show Name<br>with David Doggett<br>Monday at 11 PM<br>No Genre';
    DH[2][13] = 'No Show Name<br>with Michelle Caillouet<br>Tuesday at 1 PM<br>Rock';
    DH[2][16] = 'No Show Name<br>with Sweet Action Jackson<br>Tuesday at 4 PM<br>Rock';
    DH[2][20] = 'The Rock Hour<br>with Dan the Man<br>Tuesday at 8 PM<br>No Genre';
    DH[3][10] = 'Love Me! Hate Me!<br>with DJ Nia<br>Wednesday at 10 AM<br>No Genre';
    DH[3][11] = 'Westcoast Wednesdays<br>with DJ Smoove<br>Wednesday at 11 AM<br>No Genre';
    DH[3][15] = 'The Storm Hour<br>with the Weatherman and Reba<br>Wednesday 3 to 5 PM<br>Classic Rock';
    DH[3][16] = 'The Storm Hour<br>with the Weatherman and Reba<br>Wednesday at 4 PM<br>Classic Rock';
    DH[3][22] = 'EZ Does It<br>with DJ EZ<br>Wednesday at 10 PM<br>Rap';
    DH[4][12] = 'The Quad Show<br>with J Bean & LongJohn<br>Thursday Noon to 2 PM<br>Rap/Urban';
    DH[4][13] = 'The Quad Show<br>with J Bean & LongJohn<br>Thursday at 1 PM<br>Rap/Urban';
    DH[4][14] = 'The Hour<br>with DJ V-Jeezy<br>Thursday at 2 PM<br>No Genre';
    DH[4][15] = 'No Show Name<br>with DJ Savana<br>Thursday at 3 PM<br>No Genre';
    DH[5][10] = 'The Christian Hour<br>with Jammin J<br>Friday 10 to Noon<br>Christian';
    DH[5][11] = 'The Christian Hour<br>with Jammin J<br>Friday at 11 AM<br>Christian';
    DH[5][12] = 'The Em and Tag Show<br>with Em and Tag<br>Friday Noon to 2 PM<br>Rock';
    DH[5][13] = 'The Em and Tag Show<br>with Em and Tag<br>Friday at 1 PM<br>Rock';
    DH[5][14] = 'No Show Name<br>with DJ Kevin<br>Friday at 3 PM<br>No Genre';
    DH[5][15] = 'Big Hamptons Block<br>with Big Hampton<br>Friday 4 to 6 PM<br>Rap';
    DH[5][16] = 'Big Hamptons Block<br>with Big Hampton<br>Friday at 5 PM<br>Rap';
    DH[5][22] = 'Rockin till Midnight<br>with DJ Werewolf<br>Friday 10 to Midnight<br>Rock';
    DH[5][23] = 'Rockin till Midnight<br>with DJ Werewolf<br>Friday at 11 PM<br>Rock';
    This is for a LEGAL radio station with all the licences.

    Thanks


    CB

  2. #2
    Danno13's Avatar
    Join Date
    Jun 2005
    Location
    Worcestershire, West Midlands/Cotswolds Border
    Age
    37
    Posts
    4,903

    Default

    This line should have another quotation mark -

    if (showOn == ''")

    Not sure about this line either.. how does it know to print the php variable? You can't put an echo around it either because that would mess up the javascript variables that are added in.

    var showOn = DH[dayofweek][hourofday];

    Oh, and the include file is a html one? So how is it setting those as PHP variables?

    Personally, I'd do it either all in javascript or all in PHP, mixing the two is complicated and doesn't really serve any purpose.
    Last edited by Danno13; 29-06-2009 at 11:12 PM.
    DJs, PA, Lighting & AV Hire, LED Uplighting & Wedding Lighting, Dance Floor Hire, Starcloth & Room Decor - Covering the Midlands & Cotswolds.
    Revolution Event Services Ltd - Wedding Lighting
    01386 898 113

  3. #3
    Web Guru Marc J's Avatar
    Join Date
    Feb 2007
    Location
    Edinburgh
    Posts
    3,340

    Default

    Quote Originally Posted by Danno13 View Post
    This line should have another quotation mark -

    if (showOn == ''")
    It's already closed, it's actually two single quotes (') in Callum's code.

    Not sure about this line either.. how does it know to print the php variable? You can't put an echo around it either because that would mess up the javascript variables that are added in.

    var showOn = DH[dayofweek][hourofday];

    Oh, and the include file is a html one? So how is it setting those as PHP variables?
    I think Callum has included the html file with PHP for simpler editing, i.e. if other scheduled times are to be added then it's just a case of editing that file rather than the main one. It's only been included using PHP, it's content can be anything. In this case it's just more javascript code and is included in the main file as such. Other than the <?php include ('times.html') ?> line, there's no PHP at all.

    Personally, I'd do it either all in javascript or all in PHP, mixing the two is complicated and doesn't really serve any purpose
    Javascript is client side and PHP is server side. Some things can be done with Javascript only, and others with PHP. And some things can be done by combining the two. For example, if Callums show times were held in a database and he wanted to access that using PHP, the included file could have PHP code to pull the data from the database and write javascript variable definitions for each one.

    Anyway. Back to the OP, I gave it a quick scan and nothing obvious popped out. I'll have a closer look but this line should have a ( in it: -

    <div id='NowOn'><script type="text/javascript"> document.write(NowON());</script></div>

  4. #4
    Web Guru Marc J's Avatar
    Join Date
    Feb 2007
    Location
    Edinburgh
    Posts
    3,340

    Default

    I had a closer look and apart from a space inside "Th ursday", it's fine.

    Since you're using a PHP include in there, though, remember main file MUST have a .php extension

  5. #5
    Jiggles's Avatar
    Join Date
    Mar 2006
    Location
    Edinburgh, Scotland.
    Age
    32
    Posts
    8,327

    Default

    Still hasn't worked This was the only thing like it that I could find on the net! Plus I don't have a good knowledge of PHP to do in that.

    This is the same idea of what I get as an output:

    Auto DJ is now on. 2 hour loop of tunes!

    undefined <----This is what's bugging me!
    Last edited by Jiggles; 30-06-2009 at 08:04 PM.

  6. #6
    Web Guru Marc J's Avatar
    Join Date
    Feb 2007
    Location
    Edinburgh
    Posts
    3,340

    Default

    Quote Originally Posted by CB Entertainments View Post
    Still hasn't worked This was the only thing like it that I could find on the net! Plus I don't have a good knowledge of PHP to do in that.
    It's definitely OK, it worked on my test server no problem.

    Is this on my server, Callum?

  7. #7
    Jiggles's Avatar
    Join Date
    Mar 2006
    Location
    Edinburgh, Scotland.
    Age
    32
    Posts
    8,327

    Default

    Quote Originally Posted by Marc J View Post
    It's definitely OK, it worked on my test server no problem.

    Is this on my server, Callum?
    Local WAMP. It was fine then I saved it came back to it and it gave me the undefined error!


    Even on my own server its like that:
    http://fringradio.co.uk/tests/banner.php

  8. #8
    Web Guru Marc J's Avatar
    Join Date
    Feb 2007
    Location
    Edinburgh
    Posts
    3,340

    Default

    Quote Originally Posted by CB Entertainments View Post
    Local WAMP. It was fine then I saved it came back to it and it gave me the undefined error!


    Even on my own server its like that:
    http://fringradio.co.uk/tests/banner.php
    Ah, sorry I thought you meant it wasn't working at all. I get the "undefined line" too. Should be easy enough to take out...I'll be back.

    P.S. Thanks for letting me know you moved that domain! It's always handy to be able to cancel dead accounts...

  9. #9
    Jiggles's Avatar
    Join Date
    Mar 2006
    Location
    Edinburgh, Scotland.
    Age
    32
    Posts
    8,327

    Default

    Sorry for forgetting to tell you. I was concentrating so much on moving all my sites I forgot about that one. Sorry!

    Thanks for taking a look.

  10. #10
    Web Guru Marc J's Avatar
    Join Date
    Feb 2007
    Location
    Edinburgh
    Posts
    3,340

    Default

    Use: -
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <head>
    <title>Station Activity</title>

    <style type="text/css">
    td { font-size:0.6em; } /* temporary for testing purposes */
    #showBox {
    border: 2px solid red;
    font-size: 1.5em;
    color: red;
    background: yellow;
    height: 200px;
    width: 400px;
    }
    </style>

    <script type="text/javascript">

    /* NOT CURRENTLY USED
    var thedate = new Date();
    var dayofweek = thedate.getDay();
    var hourofday = thedate.getHours();

    var GMT = new Date().getTimezoneOffset();
    var offsetGMT = -5 * new Date().getTimezoneOffset()/60;
    */

    // Sun=0 1 2 3 4 5 Sat=6
    var DayOfWeek = new Array('Weekend','Monday','Tuesday','Wednesday','Th ursday','Friday','Weekend');

    var NoShow = 'No Show Scheduled<br />for KSWH';
    var DH = new Array (7);
    for (d=0; d<7; d++) {
    DH[d] = new Array (24);
    for (h=0; h<24; h++) { DH[d][h] = ''; }
    }

    <?php include ('times.html') ?>
    // Add more when schedule is known. Note: there may be better ways to do this when information is known.

    var thedate = new Date();
    var dayofweek = thedate.getDay();
    var hourofday = thedate.getHours();
    var showOn = DH[dayofweek][hourofday];
    if (showOn == '') { showOn = '<p />No Show Currently Scheduled for KSWH'; }

    function ReplaceDivContent(thediv) {
    document.getElementById(thediv).innerHTML = showOn;
    }

    </script>
    </head>
    <body>
    <div id='showBox'></div>
    <script type="text/javascript">ReplaceDivContent('showBox');</script>
    </body>
    </html>
    Probably better to put something along the lines of "enable javascript to see show details" inside the DIV by default, this will get replaced anyway.

Posting Permissions

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