i have created a drop-down box in an html page using SELECT and OPTION tags. there are 3 options A, B, and C... correspondingly there are 3 xml files exists in the same directory. i want to display a.xml file on selecting A option, b.xml file for B option. i tried my best to achieve it but cant do it yet. i want to do it only using html and javascript and no server side code.. please help me out.
well you can not use document.write after the page loads. You code will only work in IE. And lastly the onchange event does not fire if you select the same option in the select element.
yes eric, i got the problem now. i added alert(xmlObj.xml) instead of document.write(xmlObj.xml) statement. the xml file is getting displayed into alert box. it means we cannot use document.write() inside onchange() event.
but now my query is what is the alternative of document.write() to display the contents on change event of the drop down box.
Thanks Bear, i tried like this: added document.getElementById('result').innerHTML = xmldoc.documentElement.xml; inplace of alert(xmldoc.documentElement.xml);
You can't insert random XML into the DOM tree; only HTML.
If you want to display the XML document as text within the HTML DOM, you'll need to replace the < and > characters with their HTML Entity equivalents (< and >);