Splitting a string is the way I do it.

Jim


On 11/15/06, Aaron Cooper <[EMAIL PROTECTED]> wrote:

 Hi Jim, I can supply the data in any form. I think I may have found a
rather crude way of doing it and I've just finished testing it, and it seems
to work.

I am returning the data as a string in this case. Records are delimited by
a comma, fields are delimited by a colon. Like this:

Format: id:cruise_name:destination,

"1:Aaron's Cruise:Auckland,2:Another Cruise:Sydney"

I'm then doing a series of splits on the comma and colon to create a
multi-dimensional array, then loop and add listitems as normal.
function whenDataRetrievalComplete() {
  // Get a list of cruises from the server and add to the dropdown
  cruise_string = ajax.response;
  // DEBUG // alert(cruise_string);

  cruise_array = cruise_string.split(',');
  for($i=0; $i<cruise_array.length; $i++) {
   if(cruise_array[$i] != '') {
    cruise = cruise_array[$i].split(':');
    var item = new qx.ui.form.ListItem(cruise[1]);
    item.setValue(cruise[0]);
    field.add(item);
   }
  }
 }

I was just wondering if there was an easier way. Like parsing XML nodes if
I returned it that way. Like I said, what I just worked out seems to work
OK. If you see any glaring issues with the above or know of a better way,
please let me know. (e.g. Returning a multi-dimensional array from the PHP
file to JS would be perfect, but I don't think this is poss and it always
came as a string that just said "Array" when I tried.

Cheers for all your help mate
Aaron

----- Original Message -----
*From:* Jim Hunter <[EMAIL PROTECTED]>
*To:* qooxdoo Development <[email protected]>
*Sent:* Thursday, November 16, 2006 2:43 PM
*Subject:* Re: [qooxdoo-devel] Combo/Select boxes made from data

What does the data look like that is getting returned from the server?
Please provide an example of the string that is coming back.

Jim


On 11/15/06, Aaron Cooper <[EMAIL PROTECTED]> wrote:
>
>  Would anyone happen to have an example of how add list items to a
> combobox based on data returned from an AJAX call?
>
> I've got an AJAX call working fine and it can return either a string or
> XML. But I'm pulling my hair out trying to assign the results and add them
> as list items.
>
> Code so far - (Using SACK Ajax library)
>
> // Select Field (dropdown) for displaying cruises in the system (via
> AJAX)
> function ftmDataEntryCruiseComboBox (name, xPos, initialVal) {
>  var field = new qx.ui.form.ComboBox(initialVal);
>  field.setCssClassName("ftm-text-fields");
>  field.setTop(xPos);
>
>  var params = '';
>  ajax.reset;
>  ajax.requestFile = "ajax/get_cruise.php";
>  ajax.method = 'get';
>  ajax.onError = whenDataRetrievalError;
>  ajax.onCompletion = whenDataRetrievalComplete(field);
>  ajax.runAJAX();
>
>  return field;
> }
>
> function whenDataRetrievalComplete(field) {
>  // Add listitems to field using data from AJAX call
> }
>
> function whenDataRetrievalError() {
>  alert('error getting data');
> }
>
> Cheers
> Aaron
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
>
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>
>
 ------------------------------

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

------------------------------

_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to