mr. sparkle
06-26-2004, 02:35 AM
Situation: a listbox with a list generated from an XML file loads an external text file into a dynamic textbox when the user selects an item. i've got everything worked out except for one minor detail: I cannot get the text field to process HTML. I have the HTML box checked, so I know it's not that. Do I need to include a .html or .htmlText somewhere in my code? Here it is:
var XMLfile = "article_setup.xml";
importXML = new XML();
importXML.varTarget = this;
importXML.ignoreWhite = true;
importXML.onLoad = function (success)
{
if (success)
{
var vt = this.varTarget;
var root = this.firstChild;
vt.articleObj = new Object();
allArticles = root.childNodes;
for(var i=0; i<allArticles.length; i++)
{
article = allArticles[i].childNodes;
vt.articleObj["article" + i] = new Object();
vt.articleObj["article" + i].articleName = article[0].firstChild;
vt.articleObj["article" + i].articlePath = article[1].firstChild;
}
var i;
for (i=0; i<allArticles.length; i++)
{
listBox.addItem(vt.articleObj["article" + i].articleName);
}
select.onPress = function()
{
var myVariable = new LoadVars();
myVariable.onLoad = function(success)
{
if (success)
{
addText(this.article);
}
else trace("Error loading content.");
}
myVariable.load(vt.articleObj["article" + listBox.getSelectedIndex()].articlePath);
}
}
else
{
trace("ERROR PARSING XML");
}
};
function addText(textContent)
{
pbox.text = textContent;
}
importXML.load(XMLfile);
I will be eternally grateful if anyone has any ideas, because I'll finally be able to start loading content into the site, and eventually get it online! Thank you, thank you.
var XMLfile = "article_setup.xml";
importXML = new XML();
importXML.varTarget = this;
importXML.ignoreWhite = true;
importXML.onLoad = function (success)
{
if (success)
{
var vt = this.varTarget;
var root = this.firstChild;
vt.articleObj = new Object();
allArticles = root.childNodes;
for(var i=0; i<allArticles.length; i++)
{
article = allArticles[i].childNodes;
vt.articleObj["article" + i] = new Object();
vt.articleObj["article" + i].articleName = article[0].firstChild;
vt.articleObj["article" + i].articlePath = article[1].firstChild;
}
var i;
for (i=0; i<allArticles.length; i++)
{
listBox.addItem(vt.articleObj["article" + i].articleName);
}
select.onPress = function()
{
var myVariable = new LoadVars();
myVariable.onLoad = function(success)
{
if (success)
{
addText(this.article);
}
else trace("Error loading content.");
}
myVariable.load(vt.articleObj["article" + listBox.getSelectedIndex()].articlePath);
}
}
else
{
trace("ERROR PARSING XML");
}
};
function addText(textContent)
{
pbox.text = textContent;
}
importXML.load(XMLfile);
I will be eternally grateful if anyone has any ideas, because I'll finally be able to start loading content into the site, and eventually get it online! Thank you, thank you.