Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-03-2002, 08:03 AM   PM User | #1
k3rl
New to the CF scene

 
Join Date: Jul 2002
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
k3rl is an unknown quantity at this point
retrieve data from xml using javascript

i'm planning to create two pulldown menus. the first pulldown menu will display car makes such as toyota, ford, etc. this data is retrieved from an xml file. at this stage, the second pulldown menu will remain empty. when a person select toyota from the first pulldown menu, the second pulldown menu will automatically display the toyota models such as camry, corolla, prado, etc. this feature has to be dynamic. if the xml file is updated with a new toyota model, for eg, altis, then the second pulldown menu will be able to display the model altis as well.

how could i do this? could anyone at least suggest some sites which could help me figure out how to create this feature?

Thank you very much for your time and help.
k3rl is offline   Reply With Quote
Old 07-03-2002, 03:11 PM   PM User | #2
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
Using the W3C DOM2 Core Recommendation createDocument method and the W3C DOM3 Load And Save Working Draft load method:

var doc = document.implementation.createDocument('','',null);
doc.addEventListener('load', someEventListener, false);
doc.load('theuritothexmlfile.xml');

And when the xml file is loaded, someEventListener(event) is fired.

This is for Gecko-only at the moment (NS6, NS7, Mozilla, Beonex, K-meleon, Galeon, etc).

IE supports its own, proprietary way with a well-publicized ActiveX object:

var doc = new ActiveXObject('Microsoft.XMLDOM');
doc.attachEvent('onreadystatechange', function() { if (event.target.readyState == 4) someEventListener() });
doc.load('theuritothexmlfile.xml');

Also, both browsers implement a proprietary XMLHttpRequest object:

// in IE:
var xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');

// in Gecko:
var xmlhttp = new XMLHttpRequest();

And once the object is defined, they both function
accordingly to http://msdn.microsoft.com/library/de...ttprequest.asp
In Gecko, all methods start with a lowercase letter, and some properties aren't implemented (i.e. use xmlhttp.send() and not xmlhttp.Send())
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:24 PM.


Advertisement
Log in to turn off these ads.