Dynamically Created List of Links Made with Javascript

brought to you by the CyberIP

Special thanks and credit for the UH-1H Iroquois cockpit image goes to photographer: “[Rob Neil.Pacific Wings] @ Pixstel”.

Source Code

<script type="text/javascript">
        /*Array containing critical element of link and the link text*/
    var metals = ["Gold", "Silver", "Copper", "Platinum", "Brass", "Bronze", "Lead", "Tin"];
        /* javascript function that creates the dynamic list of links*/
    function theCyberIPLinkCreationFunction() {
        document.getElementById("myButton").style.display = "none"; /*gets rid of button when function runs*/
        for (i = 0; i < metals.length; i++) {
            var node = document.createElement("li"); /*creates a list item*/
            var a = document.createElement('a'); /*creates an anchor tag*/
            var linkText = document.createTextNode(metals[i]); /*creates the link text*/
            a.setAttribute('href', 'http://en.wikipedia.org/wiki/'+metals[i]); /*creates the URL to be accessed*/
            a.setAttribute('target', '_blank'); /*applies the target attribute*/
            a.appendChild(linkText); /*applies the desired link text*/
            document.getElementById("myLinkList").appendChild(node).appendChild(a); /*links appended into List*/
        }
    }
</script>

再见!