Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript array write html table
    primarykey
    data
    text
    <p>I am trying to create a table like so: picture here: <a href="http://speedy.sh/JahdC/Screen-Shot-2013-03-28-at-8.12.08-PM.png" rel="nofollow">http://speedy.sh/JahdC/Screen-Shot-2013-03-28-at-8.12.08-PM.png</a></p> <pre><code>___________________________________ |function|X|Y|function(x,y) | |x+y |rndX|rndY|Result of function| |x+1 | "" "" "" |x/y | "" "" "" |x%y |square root(x^2 + y^2) |x^2 |10*x + y/2 |SUM of all results </code></pre> <p>the code I currently have is: <a href="http://jsfiddle.net/wMF5M/10/" rel="nofollow">http://jsfiddle.net/wMF5M/10/</a></p> <pre><code>&lt;table id="content" border="1"&gt;&lt;/table&gt; function RandX() { var x = Math.floor(Math.random() * 300); return x; } function RandY() { var y = Math.floor(Math.random() * 300); return y; } var math1 = function (x, y) { return x * y; }; var math2 = function (x, y) { return x + 1; }; var math3 = function (x, y) { return x / y; }; var math4 = function (x, y) { return x % y; }; var math5 = function (x, y) { return math.sqrt(x ^ 2 + y ^ 2); }; var math6 = function (x, y) { return x ^ 2; }; var math7 = function (x, y) { return (10 * x) + (y / 2); }; var math8 = function (x, y) { return ((x * y) + (x + 1) + (x / y) + (x % y) + (math.sqrt(x ^ 2 + y ^ 2)) + (x ^ 2) + ((10 * x) + (y / 2))); }; // the function above is supposed to add the results of all functions together, and push into the array to be displayed var maths = []; maths.push(math1); maths.push(math2); maths.push(math3); maths.push(math4); maths.push(math5); maths.push(math6); maths.push(math7); maths.push(math8); //maths[0](RandX,2);//return RandX* RandY //maths[1](3,4);//12 - put random numbners here? var content = document.getElementById("content"); var tr = document.createElement("tr"); for (var i = 0; i &lt; maths.length; i++) { var td = document.createElement('td'); td.innerHTML = +maths[0](RandX(), RandY()); tr.appendChild(td); } content.appendChild(tr); </code></pre> <p>Using this method how do I write the first row of the table, keeping this formatting? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload