Results 1 to 2 of 2

Thread: Adding a <UL> and <a>'s using the DOM (document object model)

Threaded View

  1. #1

    Thread Starter
    Fanatic Member damasterjo's Avatar
    Join Date
    Nov 2005
    Location
    In front of my Comp DirectX7 EXpert
    Posts
    827

    Arrow Adding a <UL> and <a>'s using the DOM (document object model)

    Code:
    	
    HTML CODE
    
    	<div id="nav">
    
    	</div>
    
    JAVASCRIPT CODE
    
    function makeAutoLinks(){
    	
    	contentEdit = document.getElementById("nav");
    		ul = document.createElement("ul");
    		li1 = document.createElement("li");
    		a1 = document.createElement("a");
    		a1.setattribute('href','index.html');
    		a1.appendChild(document.createTextNode('Home'));
    			contentEdit.appendChild(ul);
    			contentEdit.appendChild(li1);
    			contentEdit.appendChild(a1);
    	}
    i am trying to make it where my page im working on all the links can be added dynamically so when i need to change a link on the site i dont have to change EVERY page.
    www.disasterexpertsinc.com
    thats the site, the news bar on the right and the stuff under the nav bar is added dynamically, i want to add the links to, the code above dosent work.

    please advise what im doing wrong.

    -damasterjo
    Last edited by damasterjo; Sep 22nd, 2008 at 02:54 PM.
    Software languages known:
    Qbasic - TI-Basic - Liberty Basic - Visual Basic 6
    Software API's known:
    Directx 7 and 8
    Internet languages, in the process of learning:
    HTML - JAVASCRIPT - PHP - CSS - MYSQL - AJAX

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width