Hi, I am trying to setup a form that will contain several events. I would like to make it so that after the show date the block of code would automatically disappear. I have looked into a couple sets of code and found the code below. However to my knowledge document.write doesn't really work well with building a table from multiple entries. Does anyone have any ideas on what would be better?
Thanks
Thanks
Code:
<script>
function autoExpire(M,D,Y,Content)
{
//document.write(M);
//document.write(D);
//document.write(Y);
var goLiveMonth = "08" // Month you want your content to start displaying. Two digits.
var goLiveDay = "08" // Day you want your content to start displaying. Two digits.
var goLiveYear = "2008" // Year you want your content to start displaying. Four digits.
var expireMonth = M // Month you want your content to stop displaying. Two digits.
var expireDay = D // Day you want your content to stop displaying. Two digits.
var expireYear = Y // Year you want your content to stop displaying. Four digits.
/* This is where you put your content. Make sure you escape any quotation marks with a backslash. Make sure you do not delete the opening and closing quotes. */
//document.write("<br />"+expireMonth);
//document.write(expireDay);
//document.write(expireYear);
var myContent = (Content)
/* Don't edit below this line. Don */
var goLiveDate = goLiveYear+ "" + goLiveMonth+ "" + goLiveDay; // puts START year, month, and day together.
if (expireMonth < 10) { /* if less than "10", put a "0" in front of the number. */
expireMonth = "0" + expireMonth;
}
//document.write(expireDay);
var expireDate = expireYear+ "" + expireMonth+ "" + expireDay; // puts EXPIRE year, month, and day together.
var nowDate = new Date();
var day = nowDate.getUTCDate();
var month = nowDate.getUTCMonth();
var correctedMonth = month + 1; //month - JavaScript starts at "0" for January, so we add "1"
if (correctedMonth < 10) { /* if less than "10", put a "0" in front of the number. */
correctedMonth = "0" + correctedMonth;
}
if (day < 10) { /* if less than "10", put a "0" in front of the number. */
day = "0" + day;
}
var year = nowDate.getYear(); /* Get the year. Firefox and Netscape might use century bit, and two-digit year. */
if (year < 1900) {
year = year + 1900; /*This is to make sure Netscape AND FireFox doesn't show the year as "107" for "2007." */
}
var GMTdate = year + "" + correctedMonth + "" + day; //corrected month GMT date.
//document.write("<br />"+GMTdate);
//document.write("<br />"+expireDate);
if ((GMTdate <= expireDate) && (GMTdate >= goLiveDate)) {
document.write(myContent);
}
}
</script>
<html>
<body onLoad=autoExpire(03,22,2013,"Test");>
<p>An error has occured on the page!</p>
</body>
</html>