# A little AS code help needed

**URL:** <https://forum.kirupa.com/t/a-little-as-code-help-needed/169359>\
**Category:** Uncategorized\
**Created:** [November 15, 2005, 6:12pm UTC](https://forum.kirupa.com/t/a-little-as-code-help-needed/169359 "2005-11-15T18:12:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![spectreman](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@spectreman](https://forum.kirupa.com/u/spectreman)\
**Post date:** [November 15, 2005, 6:12pm UTC](https://forum.kirupa.com/t/a-little-as-code-help-needed/169359/1 "2005-11-15T18:12:29Z")

</div>

hey everyone!

i’m trying to add an email field to a guestbook. i thought i had everything in order, but the entries won’t “stick”. in other words, after i add the info (name, email, message), it appears as a new entry in the guestbook, but after refreshing the page, that new entry is no longer there. can someone check my code and let me know why it’s not permanently writing to the file?

thanks!

here is the code:

var currPage = 0;  
var showAmount = 50;  
// set this to the amount of entries you want to view at a time  
previous.\_visible = false;  
createMessage.\_visible = false;  
createButton.onRelease = function() {  
this.\_visible = false;  
this.\_parent.createMessage.\_visible = true;  
if (createMessage.nameField.emailField.text == “”) {  
Selection.setFocus(createMessage.nameField.emailField);  
} else if (createMessage.messageField.emailField.text == “”) {  
Selection.setFocus(createMessage.messageField.emailField);  
}  
};  
// \*\*\*\* 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(“guestbook.xml?uniq=”+myIdentifier);  
receiverXML.onLoad = function() {  
this.contentType = “text/xml”;  
\_root.currPage = 0;  
this.showXML();  
};  
createMessage.closeButton.onRelease = function() {  
this.\_parent.\_visible = false;  
createButton.\_visible = true;  
};  
createMessage.sendButton.onRelease = function() {  
var myName = this.\_parent.nameField.text;  
var myEmail = this.\_parent.emailField.text;  
var myMessage = this.\_parent.messageField.text;  
if (myName == “”) {  
this.\_parent.errorField.text = “please fill out your name”;  
Selection.setFocus(this.\_parent.nameField);  
} else if (myEmail == “”) {  
this.\_parent.errorField.text = “please fill out your email”;  
Selection.setFocus(this.\_parent.emailField);  
} else if (myMessage == “”) {  
this.\_parent.errorField.text = “please leave a message”;  
Selection.setFocus(this.\_parent.messageField);  
} else {  
myXML.firstChild.appendChild(myXML.createElement(“entry”));  
myXML.firstChild.lastChild.attributes.myName = myName;  
myXML.firstChild.lastChild.attributes.myEmail = myEmail;  
myXML.firstChild.lastChild.appendChild(myXML.createElement(“myText”));  
myXML.firstChild.lastChild.lastChild.appendChild(myXML.createTextNode(myMessage));  
myXML.sendAndLoad(“processXML.php”, receiverXML);  
this.\_parent.\_visible = false;  
createButton.\_visible = true;  
}  
};  
XML.prototype.showXML = function() {  
myGuestbook.scroll = 1;  
myGuestbook.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;  
}  
myCount.text = "Total messages: "+numItems;  
if (firstItem == lastItem+1) {  
nowShowing.text = "Showing message “+firstItem;  
} else {  
nowShowing.text = “Showing message “+firstItem+” to “+(lastItem+1);  
}  
for (i=(firstItem-1); i\>=lastItem; i–) {  
myGuestbook.htmlText += “\<B\>”+this.firstChild.childNodes\*.attributes.myName+”\</B\>”  
myGuestbook.htmlText += “\<B\>”+this.firstChild.childNodes\*.attributes.myEmail+”\</B\> wrote:  
“;  
myGuestbook.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;  
};
