Syntax for Looping through Field Values

I need to retrieve the string values from some dynamic text fields. Each row of data contains approximately 5 different items and I need to loop through the rows and stuff the results into a variable, which I call “productInfo”. The results will be sent off as an email message (with PHP). Here’s the code:


function getCartValues() {
    for (var i:Number = 1; i <= count; i++) {
        if (table_mc["display" + i + "_mc"].p_lb.text != undefined) {
            var prod_num = table_mc["display" + i + "_mc"].p_lb.text;
            var iso_num = table_mc["display" + i + "_mc"].i_lb.text;
            var elem_name = table_mc["display" + i + "_mc"].el_lb.text;
            var chem_form = table_mc["display" + i + "_mc"].ch_cb.getValue();
            var amount = table_mc["display" + i + "_mc"].q_num.value;
            productInfo += "Product No.: " + prod_num + "%20%20%20%20%20" + "Element: " + elem_name + "%20%20%20%20%20" + "Isotope: " + iso_num + "%20%20%20%20%20" + "Chemical Form: " + chem_form + "%20%20%20%20%20" + "Quantity: " + amount + "%0a";
        }
    }
}

If I trace the first var “prod_num” I get a list that looks just the way it’s supposed to, but if I try to gather the data from all the vars into one (productInfo) I get a mess:


trace(prod_num);
//Results:
51-02-121
51-02-123
18-03-38
18-03-40
56-02-130
56-02-132
56-02-134
48-01-106

trace(productInfo);
//Results:
Product No.: 51-02-121%20%20%20%20%20Element: Antimony%20%20%20%20%20Isotope: 121Sb%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0a
Product No.: 51-02-121%20%20%20%20%20Element: Antimony%20%20%20%20%20Isotope: 121Sb%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 51-02-123%20%20%20%20%20Element: Antimony%20%20%20%20%20Isotope: 123Sb%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0a
Product No.: 51-02-121%20%20%20%20%20Element: Antimony%20%20%20%20%20Isotope: 121Sb%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 51-02-123%20%20%20%20%20Element: Antimony%20%20%20%20%20Isotope: 123Sb%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 18-03-38%20%20%20%20%20Element: Argon%20%20%20%20%20Isotope: 38Ar%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0a
Product No.: 51-02-121%20%20%20%20%20Element: Antimony%20%20%20%20%20Isotope: 121Sb%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 51-02-123%20%20%20%20%20Element: Antimony%20%20%20%20%20Isotope: 123Sb%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 18-03-38%20%20%20%20%20Element: Argon%20%20%20%20%20Isotope: 38Ar%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 18-03-40%20%20%20%20%20Element: Argon%20%20%20%20%20Isotope: 40Ar%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0a
Product No.: 51-02-121%20%20%20%20%20Element: Antimony%20%20%20%20%20Isotope: 121Sb%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 51-02-123%20%20%20%20%20Element: Antimony%20%20%20%20%20Isotope: 123Sb%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 18-03-38%20%20%20%20%20Element: Argon%20%20%20%20%20Isotope: 38Ar%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 18-03-40%20%20%20%20%20Element: Argon%20%20%20%20%20Isotope: 40Ar%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 56-02-130%20%20%20%20%20Element: Barium%20%20%20%20%20Isotope: 130Ba%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0a
Product No.: 51-02-121%20%20%20%20%20Element: Antimony%20%20%20%20%20Isotope: 121Sb%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 51-02-123%20%20%20%20%20Element: Antimony%20%20%20%20%20Isotope: 123Sb%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 18-03-38%20%20%20%20%20Element: Argon%20%20%20%20%20Isotope: 38Ar%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 18-03-40%20%20%20%20%20Element: Argon%20%20%20%20%20Isotope: 40Ar%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 56-02-130%20%20%20%20%20Element: Barium%20%20%20%20%20Isotope: 130Ba%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 56-02-132%20%20%20%20%20Element: Barium%20%20%20%20%20Isotope: 132Ba%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0a
Product No.: 51-02-121%20%20%20%20%20Element: Antimony%20%20%20%20%20Isotope: 121Sb%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 51-02-123%20%20%20%20%20Element: Antimony%20%20%20%20%20Isotope: 123Sb%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 18-03-38%20%20%20%20%20Element: Argon%20%20%20%20%20Isotope: 38Ar%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 18-03-40%20%20%20%20%20Element: Argon%20%20%20%20%20Isotope: 40Ar%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 56-02-130%20%20%20%20%20Element: Barium%20%20%20%20%20Isotope: 130Ba%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 56-02-132%20%20%20%20%20Element: Barium%20%20%20%20%20Isotope: 132Ba%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 56-02-134%20%20%20%20%20Element: Barium%20%20%20%20%20Isotope: 134Ba%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0a
Product No.: 51-02-121%20%20%20%20%20Element: Antimony%20%20%20%20%20Isotope: 121Sb%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 51-02-123%20%20%20%20%20Element: Antimony%20%20%20%20%20Isotope: 123Sb%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 18-03-38%20%20%20%20%20Element: Argon%20%20%20%20%20Isotope: 38Ar%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 18-03-40%20%20%20%20%20Element: Argon%20%20%20%20%20Isotope: 40Ar%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 56-02-130%20%20%20%20%20Element: Barium%20%20%20%20%20Isotope: 130Ba%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 56-02-132%20%20%20%20%20Element: Barium%20%20%20%20%20Isotope: 132Ba%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 56-02-134%20%20%20%20%20Element: Barium%20%20%20%20%20Isotope: 134Ba%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0aProduct No.: 48-01-106%20%20%20%20%20Element: Cadmium%20%20%20%20%20Isotope: 106Cd%20%20%20%20%20Chemical Form: %20%20%20%20%20Quantity: 0%0a

I’m kind of bleary eyed - Can someone tell me what’s wrong with the syntax?