0

I want my code yo retreive an xml file and display it as an options list under a select object but the code in google chrome is giving this error "Uncaught TypeError: Cannot read property '0' of undefined" and i dont know what to do about it please can someone help me.

 <script type="text/ecmascript">
        var oreofe;

        var xmlHttpDoc = new XMLHttpRequest();
             function loadWing()
            {
                var build = document.getElementsByName('building').item().value;
                alert(build);
                    if(xmlHttpDoc)
                    {
                        xmlHttpDoc.open("GET", "test.php?ret=build", true);
                        xmlHttpDoc.onreadystatechange = function()
                        {
                              if(xmlHttpDoc.readyState==4 && xmlHttpDoc.status==200)
                              {
                                  var xmlDocument;
                                  xmlDocument = xmlHttpDoc.responseXML;
                                  oreofe = xmlDocument.getElementsByTagName('option');
                                  listOptions();
                              }
                        }
                        xmlHttpDoc.send(null);
                    }               
            }

             function listOptions()
            {
              var loopIndex;
                    for (loopIndex = 0; loopIndex < oreofe.length; loopIndex++ )
                    {
                        document.getElementsByName('wing').options[loopIndex].v = new Option(oreofe[loopIndex].firstChild.data);
                    }
            }
        </script>


        this is the html part

         <p><label>Problem Location Building</label></p>
                        <p><select name="building" onchange="loadWing()"><option value="daniel">Daniel Hall</option><option value="john">John Hall</option><option value="esther">Esther Hall</option><option value="deborah">Deborah Hall</option></select></p>
                        <p><label>Problem Location Wing</label></p>
                        <p><select name="wing" ><option>Select a scheme</option></select></p>
1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Ralphael
0

Why is any body not helping me I really need this for my FInal year Project

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.