[thelist] Simple JavaScript not working head scratcher

Peter Brunone (EasyListBox.com) peter at easylistbox.com
Fri Mar 3 15:10:26 CST 2006


Matt will probably have my head, but what about    var items = lists[0].getElementsByTagName("li");
for (var i=0;i<items.length;i++)
{
items[i].innerHTML = "<a href='#'>" + items[i].innerHTML + "</a>";
}

?  If that doesn't work, let us know what's happening (error message, unexpected results, absolutely nothing) and we'll sort it out.

Cheers,

Peter

----------------------------------------
  From: fstorr <fffrancis at fstorr.demon.co.uk>
Sent: Friday, March 03, 2006 1:56 PM
To: Evolt <thelist at lists.evolt.org>
Subject: [thelist] Simple JavaScript not working head scratcher 

Hi all

This should be simple, but for some reason I can't work out why this 
isn't working. This is what I've got:

 Quarter 1
 Quarter 2

And this is what I want:

 Quarter 1
 Quarter 2

Before anyone says anything, yes I know using JS to insert links is 
bad - this whole thing started off as a "I'll just write this script 
for a couple of quick development tasks to show proof of concept" and 
now it's just something that I can't get working. In the actual 
document everything works fine except the inserting bit - I've tried 
using appendChild, firstChild.insertBefore and just about everything 
else, but it just won't play. Here's what I've got:

function alertnone()
 {
 var content = document.getElementById("content");
 var lists = content.getElementsByTagName("ul");
 var items = lists[0].getElementsByTagName("li");
 for (var i=0;i 

 Quarter 1 link
 Quarter 2 link
 Quarter 3 link

Cheers

F

-- 

* * Please support the community that supports you. * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 





More information about the thelist mailing list