A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: loading data to combo box from xml

  1. #1
    Junior Member
    Join Date
    Oct 2005
    Posts
    12

    loading data to combo box from xml

    iam unable to load all the data from xml file to combo box................


    this my code in the first frame:


    var My_order:XML = new XML();
    My_order.ignoreWhite = true;
    My_order.load("company_name.xml");
    //
    My_order.onLoad = function(success) {
    if (success) {
    comp_brandArray = My_order.firstChild.childNodes;
    for (var i = 0; i<comp_brandArray.length; i++) {
    company.addItem({label:comp_brandArray[0].firstChild.attributes.name, data:i});
    }
    } else {
    import mx.controls.Alert;
    Alert.show("Unable to connect to server. Pls try after some time.........", "Error");
    }
    };
    //--------------


    any help is appreciated thanks in advance
    Attached Files Attached Files

  2. #2
    Flash Gordon McUsher's Avatar
    Join Date
    Mar 2001
    Location
    Krautland
    Posts
    1,560
    Well you use My_order.load("company_name.xml");
    but your xml file is named "company_name.txt"...

    Quite an easy error
    My letters on the F1 key have faded, how are yours today?

  3. #3
    Junior Member
    Join Date
    Oct 2005
    Posts
    12
    sorry for delayed reply McUsher but i couldn't upload the xml file i have attached it as txt file as u can see in the previous code!

    i could do this way

    My_order.onLoad = function(success) {
    if (success) {
    comp_brandArray = My_order.firstChild.childNodes;
    for (var i = 0; i<comp_brandArray.length; i++) {
    company.addItem({label:comp_brandArray[i].firstChild.attributes.name, data:i});

    }
    } else {
    import mx.controls.Alert;
    Alert.show("Unable to connect to server. Pls try after some time.........", "Error");
    }
    };

    some other solution here i am skippin some of the data any help!

  4. #4
    Flash Gordon McUsher's Avatar
    Join Date
    Mar 2001
    Location
    Krautland
    Posts
    1,560
    Oh, i think you should only change one thing:
    My_order.onLoad = function(success) {
    if (success) {
    comp_brandArray = this.firstChild.childNodes;
    My letters on the F1 key have faded, how are yours today?

  5. #5
    Junior Member
    Join Date
    Oct 2005
    Posts
    12

    loading data to combo box from xml

    hey i figured out here is the code,i got help from my friend, thanks McUsher.........

    My_order.onLoad = function(success) {
    if (success) {
    comp_Array = My_order.firstChild.childNodes;
    for (var i = 0; i<comp_Array.length; i++) {
    var lengthOfAtr = comp_Array[i].childNodes.length;
    for (var j = 0; j<lengthOfAtr; j++) {
    if (comp_Array[i].childNodes[j].nodeName == "company") {
    company.addItem({label:comp_Array[i].childNodes[j].attributes.name, data:i});
    } else {
    brandlist.addItem({label:comp_Array[i].childNodes[j].attributes.name, data:i});
    }
    }
    }
    } else {
    import mx.controls.Alert;
    Alert.show("Unable to connect to server. Pls try after some time.........", "Error");
    }
    };

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center