Ok. I don't kno how, but I messed up my original html file somehow, and I can't revert it back. I don't know what I changed. and I can't transfer my list to an array of arrays in Javascript. I did that once, it worked to perfection, but I can't re-do it now. I haven't changed the source, just messed up some code in my blocks or my HTML. Whatever happened, I decided to get this sample into my computer and try to play with it to learn:
PuravidaApps: Table.
Firs I run it as it is, it works. next, I added a web1 and called for my data. It gets the data and I changed it so it will send my data, which comes as a csv table, to webviewer. It shows everything correctly, in the table. as you can see in picture 1.
but WHen, I try to access a single item from the array, it treats the array like a string and gives me just one character. Here is what I wrote as a script:
<script>
document.write(urlArray + "<br>");
document.write("first item " + urlArray[0][1] + "<br>");
document.write("second item " + urlArray[1][4] + "<br>");
document.write("third item " + urlArray[2][3] + "<br>");
</script>
In picture 2, you can see what it brings out. I've been trying to solve for a day now, and about to go nuts! Please show me what I'm doing wrong. And also, I don't understant how the table is actually filled with items all sorted when I can't access them with code. Thanks..
urlArray is not a 2 dimensional array, see the relevant parts of the code below
Taifun
var urlArray = window.AppInventor.getWebViewString().split("\n");
for(i=0;i<urlArray.length;i++){
// split at comma
var rowArray = urlArray[i].split(",");
}
any idea how I was able to do that before? I wish I hadn't changed any part of this. Whatever, Is there a way to change it into a two dimensional array?
if anyone searches for a similar information, I want to write the solution I figured.. The "list to csv table" is NOT allowed to become a 2d array. What you need to do, is to code the entire message with the block style you can find at Taifun's web page here. In my example, I got the data from my db, then converted it to a list using "list from csv table". Then, I added every item together like this:
item1,item2,item3\nitem4,item5,item6\nitem7,item8,item9
you do this by joining them together as text strings. Then you transfer this to your webviewer, and define it an array. Then, define another array an make it equal to "your first array[0]". thisway, you don't still get a 2d array, but you just get arrays, which can later be merged into a single 2d array.
Taifun, your examples make us better rookies. Thanks.