I have found a guestbook and it works it has 2 input text fields
“Name And Message”
the XML sends the persons message and the message
pops up for all to see, works perfectly! (uses small php to do this as well)
What I want to do is have a 3rd text field
“MyScore” which will send the score to the guestbook I want it to be a dynamic text field instead of a input text field to help stop people changing their Score I Load the score into the dynamic text like this:
- Dynamic text field has the instance name of MyScore
- The Var is named MyScorePoints
[AS]var MyScorePoints = "Broly The Turbo Turban kills: " + _root.total2 + " Diamond kills: " + _root.Roam + " Suzie Lou Horde kills: " + _root.total
[/AS]
that loads just fine !
The trouble I am having is setting it up so the score is posted to the guestbook Here how the main code looks that works perfect when posting name and comment:
[AS]var currPage = 0;
var showAmount = 10; // 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.text == “”){
Selection.setFocus(createMessage.nameField);
}
else if (createMessage.messageField.text == “”){
Selection.setFocus(createMessage.messageField);
}
}
// **** 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 myMessage = this._parent.messageField.text;
if (myName == “”){
this._parent.errorField.text = “please fill out your name”;
Selection.setFocus(this._parent.nameField);
}
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.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 - (currPageshowAmount);
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> 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;
}
stop();
[/AS]
So how would I the 3rd dynamic text field to post to the guestbook?
Here is the XML code and Php code:
[AS]<?xml version=“1.0”?><guestbook><entry myName=“Sherwood Heros”><myText>Welcome To The Guestbook Feel free to Leave a Comment</myText></entry></guestbook>[/AS]
Php:
<?php
$file = fopen("guestbook.xml", "w+") or die("Can't open XML file");
$xmlString = $HTTP_RAW_POST_DATA;
if(!fwrite($file, $xmlString)){
print "Error writing to XML-file";
}
print $xmlString."
";
fclose($file);
?>
Thanks in advance!
tutorial this guestbook is from: http://www.kirupa.com/web/xml_guestbook.htm