[thelist] updating cascading 'select' form elements from adatabase

Diane Soini dianesoini at earthlink.net
Thu Aug 12 20:17:06 CDT 2004


On Thursday, August 12, 2004, at 04:15 AM, 
thelist-request at lists.evolt.org wrote:
>
> El jue, 12-08-2004 a las 05:38, Joel D Canfield escribió:
>>> What about using javascript and XML. Let's you make a trip to the
>>> server (for the XML file) without refreshing the HTML on the client
>>> side. Works in many modern browsers but not all, though.
>>
>> Intruiging. Can you expand on that? What's *in* the XML file? How does
>> it get there?
>
> Sorry for stepping on the middle of a conversation, but i guess he's
> referring to the xml http request object
>
> http://jibbering.com/2002/4/httprequest.html

Yes, that's what she (me) was referring to.

I am not sure how the data would get into your xml file. You could 
create your xml files by hand, or generate them dynamically. What's in 
them is up to you.  And there are a couple ways to get the XML into 
your javascript (look up XMLDOM activex object and xmlhttp object), but 
one simple way would be:
-Drop-down one has 5 options
-You have 5 XML files containing info for Drop-down 2.
-Select something in drop-down one, javascript event loads the xml 
(maybe the selectedIndex says which file to load), parses and processes 
it, and constructs Drop-down 2.
-Drop-down 2 is added to the current html page's DOM by the javascript, 
no page refresh or iframes needed.

Not that this even begins to say what you could do with this technique. 
But imagine generating the XML file with a php script that queries a 
database to return xml content when your javascript calls an xml.load 
function. Or just imagine each XML file is really just static HTML with 
your <select> list number 2, and that is what is loaded, kinda like a 
plain old server-side include.

With httprequest object you can choose to parse the XML as XML  (so you 
can do DOM things to it) or as just text (so you can do 
text-manipulation things to it).

The rest of it is really up to your imagination.




More information about the thelist mailing list