I'm using Fusion Tables to store a URL to my Google Drive Photos (stored in the column Link).
I'm using JavaScript to query Fusion Tables to get all the URLs and then create a table with 3 items picked randomly from the data.
The code I add underneath let me see 3 first photos ... i have tried to switch the line
contentStr += "<td><img src=" + item[j]+"></td>";
to
contentStr += "<td><img src=" + randomElement[j]+"></td>";
but it doesn't work. Does anyone can help me please?
<head>
<title>Test</title>
</head>
<body>
<div id="content"></div>
<script>
function handler(response) {
var maxFoto = response.rows.length
var contentStr = "<table>";
for (var i = 0; i < 3; i++) {
var item = response.rows[i];
var randomFoto = Math.floor(Math.random()*maxFoto);
var randomElement = item[randomFoto];
contentStr += "<tr>";
for (var j = 0; j < item.length; j++) {
contentStr += "<td><img src=" + item[j]+"></td>";
}
contentStr += "</tr>";
}
contentStr += "</table>";
document.getElementById("content").innerHTML = contentStr;
}
</script>
<script src="http://ift.tt/1XkAPY9"></script>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire