I’m using Kirupa’s tutorial to make a guestbook using XML/PHP. I’ve been trying to add the date when a post was made to the XML file, but it’s not working the way I want. All I want is the month, day, and year to be saved to the XML file (ie 8.19.2006). However, the following actionscript adds a lot of extra date info that isn’t necessary. Everything else works perfectly except for the date. How should I modify this actionscript to only show the month, day, & year that a post was made (in this format… month.day.year)?
var currPage = 0;
var showAmount = 3; // set this to the amount of entries you want to view at a time
previous._visible = false;
// **** Load XML ****************************
myXML = new XML();
myXML.ignoreWhite = true;
receiverXML = new XML();
myXML.onLoad = function(success){
myXML.contentType = "text/xml";
if (success){
this.showXML();
}
else{
trace("Error loading XML file.");
}
}
myIdentifier=Math.round(Math.random()*10000);
myXML.load("news.xml?uniq="+myIdentifier);
receiverXML.onLoad = function(){
this.contentType = "text/xml";
_root.currPage = 0;
this.showXML();
}
sendButton.onRelease = function(){
var myMessage = this._parent.messageField.text;
if (myMessage == ""){
this._parent.errorField.text = "* Please type a message *";
Selection.setFocus(this._parent.messageField);
}
else {
myXML.firstChild.appendChild(myXML.createElement("entry"));
myXML.firstChild.lastChild.attributes.myMonth = myDate;
myXML.firstChild.lastChild.appendChild(myXML.createElement("myText"));
myXML.firstChild.lastChild.lastChild.appendChild(myXML.createTextNode(myMessage));
myXML.sendAndLoad("processXML.php", receiverXML);
}
}
XML.prototype.showXML = function(){
myText_txt.scroll = 1;
myText_txt.htmlText = "";
var numItems = this.firstChild.childNodes.length;
var firstItem = numItems - (currPage*showAmount);
if (currPage == 0) previous._visible = false;
var lastItem = firstItem - showAmount ;
if (lastItem<=0) {
lastItem = 0;
next._visible = false;
}
if (firstItem == lastItem+1) nowShowing.text = "Showing message " + firstItem;
else nowShowing.text = "Showing message " + firstItem + " to " + (lastItem + 1);
myDate= new Date();
myMonth = myDate.getMonth()+1;
myDay = myDate.getDate();
myYear = myDate.getFullYear();
for (i=(firstItem-1); i>= lastItem; i--){
myText_txt.htmlText += "<font color='#ACA2B1'>" + this.firstChild.childNodes*.attributes.myDate + "</font>
";
myText_txt.htmlText += this.firstChild.childNodes*.firstChild.firstChild.nodeValue + "
";
}
}
previous.onRelease = function(){
currPage--;
myXML.showXML();
next._visible = true;
}
next.onRelease = function(){
currPage++;
myXML.showXML();
previous._visible = true;
}