document.write() is a very primitive way of outputting data. document.write() statements must be run before the page finishes loading. Any document.write() statement that runs after the page finishes loading will create a new page and overwrite all of the content of the current page. So document.write() is at best really only useful to write the original content of your page. It cannot be used to update the content of your page after that page has loaded.
document.write() is a very primitive way of outputting data. document.write() statements must be run before the page finishes loading. Any document.write() statement that runs after the page finishes loading will create a new page and overwrite all of the content of the current page. So document.write() is at best really only useful to write the original content of your page. It cannot be used to update the content of your page after that page has loaded.
ALthough, how would that be coded to show just whos on that day... not at the particular time?
for instance to display
6-8pm John Smith
8-10pm Jenny Brown
This syntax is great, but completely new to me
UKD
Sorry, I do not understand. Is not 6-8pm John Smith 8-10pm Jenny Brown showing the particular time? Obviously if you do not want the times to display you simply remove them. But that seems to me to nullify the point of a radio schedule which informs who is on air now. If all you want to do is to list the performers of that day, then a simple list will suffice, but outputing to a <div> rather than with docuemnt.write().
Sorry, I do not understand. Is not 6-8pm John Smith 8-10pm Jenny Brown showing the particular time? Obviously if you do not want the times to display you simply remove them.
Hi,
What i actually need is a display showing who is coming up in the evening not who is on air "right now".
The radio station i am doing this for only broadcast in the evening so on monday i need it to say:
In effect you already have this, but days in Javascript are 0-6. So get the day, and display the appropriate message using the switch statement.
Code:
var d = new Date();
var theDay = d.getDay(); // days are 0 Sunday -6 Saturday
theDay = 1
switch (theDay) {
case 1:
document.write("On Air Tonight...<br>");
document.write("ALAN POWELL! <br>");
document.write("8pm - 10pm <br>");
document.write("CARL KANE! <br>");
break;
... and so on
}
And one more advice: document.write isn't good idea for displaying data. If I got you right, you need to show four different lines. Put in your HTML code 4 p tags with id. Then in javascript assign them to vars using document.getElementById and use .innerHTML to put text into them. This way you can style paragraphs as you like by CSS.