PDA

View Full Version : XMLDataModel - processing data



JasonMichael
21 Feb 2007, 6:48 PM
Hi, I understand its pretty easy to load XML data into a form, but I'm needing to just access data that I've loaded, and create a loop to make HTML 'select' options for a drop down menu. Off the top of your heads, anyone have a suggestion of where I might start? I've worked on this about an hour or so, and have been successful in using the XMLDataModel.grid to get data into memory from my web service api/AJAX proxy, but I'm such a newbie.... I'm very humbled by the whole Javascript/YUI-ext experience...

Jason

BernardChhun
23 Feb 2007, 7:32 PM
Hi, I understand its pretty easy to load XML data into a form, but I'm needing to just access data that I've loaded, and create a loop to make HTML 'select' options for a drop down menu. Off the top of your heads, anyone have a suggestion of where I might start? I've worked on this about an hour or so, and have been successful in using the XMLDataModel.grid to get data into memory from my web service api/AJAX proxy, but I'm such a newbie.... I'm very humbled by the whole Javascript/YUI-ext experience...
Jason

hmm I'm confused here...is the value for your drop down menu in the XML data for the grid? or will you make a completely different call for it?

if it's the second option I'd probably use an AsyncRequest like so:



var sUrl = 'yourUrl'
var params = 'params=popIt' ;
var callback = { success: function(o){
// o.responseText is the answer given by your url
var response = o.responseText;
// get a reference to your select box
var select = getEl('the-selec-id');
// I'd make the loop here to get to the corresponding childNode
},
failure: function(o){
alert('failed!')
};

YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, params);
}

JasonMichael
23 Feb 2007, 8:13 PM
Hi Jack,

You're precisely correct - a different call, and I believe your solution here is going to work great. I'll try it out and let you know... maybe post it here for others to check out. Thanks again,

-Jason

JasonMichael
24 Feb 2007, 2:10 PM
Actually, this solution would work if my data response wasn't an XML document... or then again, it would, but I was wondering if its possible to have multiple XML data models within one function. so far, Ive been getting some strange results.

I might be asking Javascript to do too much , as it would be easy enough to just have PHP create the option values for the drop down menu, then have a onselect call a function that would have the grid updated with a different set of data.