I need to Create a table from a loop that uses the data from an array.
I am using a sample code but i am having trouble trying to figure out how to get the loop to use an array to fill the data. I dont know what i need to put for the function portion or if I dont even need to worry about that?
<!Doctype html>
<html>
<head>
<script type="text/javascript">
function table()
{
this.calcmul = calc;
}
function calc(arg1,arg2)
{
var cars = ["Saab", "Volvo", "BMW"];
var cars2 = ["Saab", "Volvo", "BMW"];
return multi;
}
var table2 = new table();
</script>
</head>
<body>
<table border="solid 2px;" style="font-size:50px;">
<thead><tr>
<script>
for(var j=1; j<=5; j++)
{
document.write("<th><label style= color:red;'>"+i+"</label></th>");
}
</script>
</tr>
</thead>
<tbody>
<script type="text/javascript">
for(var i =1; i<=5; i++)
{
document.write("<tr>");
for(var k=1; k<=2; k++)
{
var cars = i;
var cars2 = k;
document.write("<td>"+table2.cars+"</td>");
}
document.write("</tr>");
}
</script>
</tbody>
</table>
</body>
</html>
I am trying to get the loop to create the table and list the data from the array