XML to Javascript Array Help

admin

Administrator
Staff member
I posted this thread in the Javascript forum a few days ago and didn't receive any replies, so I thought I might get better luck in the XML forum. Please help out if you can, I am eager to learn! :)

With the help of these boards I have managed to complete my first working web based application in Javascript! I've decided to continue my education and implement XML in the program as well.

Essentially, the program takes input from the user in a Textarea, it does an indexOf of an array of names, and if the indexOf==0 then it adds BBCode tags on either side of the sentence that the word was found in, then prints it into another textarea.

Let's say that the we are dealing with pizza toppings as an example. My plan was to write the XML file as such:

Code:


"Cheese","Pepperoni","Hawaiaan"


Then I planned on getting the value of [toppings] and using it in the constructor of the array through this code snippet that I found:

Code:

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("pizza.xml")
nodes = xmlDoc.documentElement.childNodes
toppings.innerText = nodes.item(0).text

//and

</b><span id="toppings"></span>


Which works great in an HTML file by itself, but when I put just the first part into the <script> tags the entire script just stops working... and it never throws an error.

So I have two questions at this point that I was hoping you folks could help me out with:
1. Is my current plan of importing the comma delimited list a good idea or should I separate each topping into it's own element?
2. What's the best methods to use?

Ultimately, my goal is to have a password protected link on the page of my main application that will take the user to the editor in a new page. The new page should contain a list of all of the current toppings, preferrably in alphabetical order. It should also contain three empty Input fields so that the user can enter their own topping, press submit, and have the page refresh with the new topping added (alphabetically) to the list and another three empty fields at the bottom of the list. It would also be a good idea to give them the option of removing toppings as well. Any suggestions?
 
Back
Top