Sie sind auf Seite 1von 4


php) App Inventor and

HTML/JavaScript with Input Parameters
App Inventor and Dynamic Table Layout
This is the App Inventor example, it also is available for App Inventor Classic here (./table2.php).
Thank you Christopher for being the sponsor of the App Inventor 2 version!
It was asked in the App Inventor Forum (
inventor/zopD9HkBnWA/discussion), how to display a table in App Inventor without knowing how many rows will be supplied.
And let me add to this requirement, without knowing how many columns will be supplied!
App Inventor together with embedded HTML/JavaScript can do that!
Thank you Craig! ( Your JavaScript example
( helped me to set up this solution.
You can use this example for your projects without need to adjust anything in the HTML document. And: it works with any desired
number of rows and/or columns! Well, if you do not like the colors etc., there are lots of possibilities you can adjust with CSS
( in the header of the HTML document.
App Inventor Blocks
Download the html file
The HTML file table.html will be downloaded on first run of the app and stored on the sd card of the device using a modified version
of the Webprefetch File by File (filebyfile.php) example.
Display the table
We pass the urlencoded ( table in csv format as parameter to the html file and use a
webviewer component to display it. That's all...
Pura Vida Apps (index.php) Apps (apps.php) Snippets (snippets.php)
Tutorials (tutorials.php) News (news.php) Forums (forum.php)
Links (links.php) Search (search.php) Contact (contact.php)
<!doctype html>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Table Layout</title>
<!--more layout possibilities see here: (>
<style type="text/css">
table { border-collapse:collapse; }
table,th,td { border:1px solid green; }
th { background-color:green; color:white; }
function urldecode(str) {
return decodeURIComponent((str+'').replace(/\+/g, '%20'));
<div id="myTable"></div>
// split at new line
var urlArray ="%0A");
var doc = document;
var fragment = doc.createDocumentFragment();
var tr = doc.createElement("tr");
// split at comma
var rowArray = urlArray[i].split("%2C");
if ( i == 0) { var td = doc.createElement("th"); }
else { var td = doc.createElement("td"); }
td.innerHTML = urldecode(rowArray[j]);
var table = doc.createElement("table");
The limit to display a table is around 2 MB (max. length of an URI) (
Questions and Answers
Q1: How would you use this example and populate it with a list of lists?
A: So your question is: how to convert a list of lists into a table in csv format? This is very easy: just use the list to csv table
( block for that.
Home (./index.php) | Apps (./apps.php) | Snippets (./snippets.php) | Tutorials (./tutorials.php) | News (./news.php) | Forums (./forum.php) |
Links (./links.php) | Search (./search.php) | Contact (./contact.php)
Site Content 2014 Pura Vida Apps ( using the Foundation Framework (
Portions of this page are modifications based on work created and shared by Google ( and used according to
terms described in the Creative Commons 3.0 Attribution License. ( Android is a trademark of Google
If you find this example helpful and you are using it in one of your projects,
be nice and donate a small amount!

Thank you! Taifun

Download aia file for App Inventor (sourceforge.php?name=table.aia)
Back to top of page ...
This work by Pura Vida Apps ( is licensed under a Creative Commons Attribution-ShareAlike 3.0
Unported License (
with attribution (name=Pura Vida Apps ( and link to the source site) required.