Using a list position as a param to a function to pull certain data
<pre><code>function getList()
    {
        var string2 = "&lt;img src='close.png' onclick='removeContent(3)'&gt;&lt;/img&gt;" + "&lt;h4&gt;Survey Findings&lt;/h4&gt;";
        string2 = string2 + "&lt;p&gt;The 15 Largest lochs in Scotland by area area...&lt;/p&gt;";  
        document.getElementById("box3text").innerHTML = string2;


        var myList = document.getElementById("testList");


        for(i=0;i&lt;lochName.length;i++)
        {


            if(i&lt;3)
            {

                var listElement = "&lt;a href='javascript:getLoch(i)'&gt;" + "Loch "+ lochName[i] + "&lt;/a&gt;";
                var container = document.getElementById("testList");
                var newListItem = document.createElement('li');
                newListItem.innerHTML = listElement;
                container.insertBefore(newListItem, container.lastChild);



            }
            else
            {

            var listElement = "Loch "+lochName[i];
            var container = document.getElementById("testList");
            var newListItem = document.createElement('li');
            newListItem.innerHTML = listElement;
            container.insertBefore(newListItem, container.lastChild);

            }

        }

    }
</code></pre>

<p>This function generates a list with the 1st 3 elements being hyperlinks. When clicked they should call a function call getLoch(i) with i being the position of the item in the list. However when i pass it the value it just give it a value of 15, the full size of the array and not the position. </p>

<p>function getLoch(Val)
    {</p>

<pre><code>    var str = "&lt;img src='close.png' onclick='removeContent(4)'&gt;&lt;/img&gt;" + "&lt;h4&gt;Loch " + lochName[Val] +"&lt;/h4&gt;";
    str = str + "&lt;ul&gt;&lt;li&gt;Area:" + " " + area[Val] + " square miles&lt;/li&gt;";
    str = str + "&lt;li&gt;Max Depth:" + " " + maxDepth[Val] + " metres deep&lt;/li&gt;";
    str = str + "&lt;li&gt;County:" + " " + county[Val] + "&lt;/li&gt;&lt;/ul&gt;";

    document.getElementById("box4").innerHTML = str;


}
</code></pre>
