All pastes #494510 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-05-18 09:01 UTC
rendered paste body
<html>

    <head>

        <script type="text/javascript">
            function myFn(x) {

                arr = [];
		
		            arr[0] = [];
		
		            arr[0][0] = [];
		
		            arr[0][0][1] = 'foo';
		            arr[0][0][2] = '';
		            arr[0][0][3] = 'baz';

                el = [];

                for (i = 0; i < arr.length; i++) {

                    el[i] = document.createElement('div');

                    if (!arr[x][i][2]) {
                        el[i].appendChild(document.createTextNode(arr[x][i][1]));
                    }

                    el[i].onclick = function(x,i) { /* Am I passing this wrong? */
                        if (arr[x][i][3]) alert(arr[x][i][3]); /* Error: "i has no properties" */
                    }

                    document.body.appendChild(el[i]);

                }

            }
						
        </script>

    </head>

    <body>

        <p onclick="myFn(0)">Click Me!</p>

    </body>

</html>