How to display a jQuery and Javascript generated 2 dimensional array in HTML?
        Posted  
        
            by 
                user1730439
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user1730439
        
        
        
        Published on 2012-10-09T03:03:37Z
        Indexed on 
            2012/10/09
            3:37 UTC
        
        
        Read the original article
        Hit count: 157
        
I am trying to create a table of 100 random numbers, the random numbers are from 0 to 100. I need to display the 100 random numbers as a 10 by 10 matrix in HTML, using JS and jQuery. The code that I have been working on displays the last array 10 times. Here is the code:
<html>
    <head>
        <title>My Web Page</title>
        <script type = "text/javascript" src = "http://code.jquery.com/jquery-1.8.2.min.js" />
        </script>
    </head>
    <body>
        <h1 id = "randData">Randomize Data</h1>
        <button id = "myRandomizeBtn">Randomize</button>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
    </body>
    <script type="text/javascript">
    $("#myRandomizeBtn").bind("click",randomizeHandler);
    function randomizeHandler(evt)
    {
        var n = 10;
        var data = new Array();
        for (var i = 0; i < n; i++)
        {
            for (var j = 0; j < n; j++)
            {
                data[i,j] = Math.floor(100*Math.random());
                $("p").text(data);
            }
            $("br").text(data);
        }
    }
    </script>
</html>
© Stack Overflow or respective owner