Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (multi-dimensional)
Viewing all articles
Browse latest Browse all 2

Dynamic form & multidimensional array

$
0
0

Hello! I've created a form with 6 rows of fields, example of 1 row:

var Row1 ={
        0 : Ti.UI.createTextField({
            [Properties ...]
        }),
        1 : Ti.UI.createTextField({
            [Properties ...]
        }),
        2 : Ti.UI.createTextField({
            [Properties ...]
        }),
        3 : Ti.UI.createTextField({
            [Properties ...]
        }),
        4 : Ti.UI.createTextField({
            [Properties ...]
        }),
        5 : Ti.UI.createTextField({
            [Properties ...]
        })
};
// Plus 5 times more with Row2, Row3
So what I am trying to do is to read the values given and putting it into a multi-dimensional array, please read the comments in the code so you can follow me
var data = new Array();
    // I am running a for look that follows "6" rows
    for( var a = 1; a <= 6; a++){
        // need to set data["RowX"] cuz appcelerator doesn't recognize it
        data["Row"+a] = new Array(); 
        var row = eval("Row" +a); // Need to do this so I can set the dynamic variable name
        // Then I try to get the values from each row within another for loop counting Row1 fields
        for(var b = 0; b < row.length; b++){
            // Then I try to set the values
            data["row"+a].push(row[b].value);
        }  
 
    }
    // Here I write in console data and I get NOTHING :/
What I wish to do is to save all 6 textfields values in the index of the row that they belong so I can then JSON.stringify and send through XHR to a PHP that will take the values from there...

Can anyone be kind enough to help me? I've tried many things, also for( var key in num) and then get values but it results the same...

Thanks anyone for reading anyway :)


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>