[thelist] DOM ol li listing issue, Please Help!!!
S.F. Alim
salim at vodatel.com
Mon Aug 15 08:20:18 CDT 2005
Thanks you quick reply, First of all --> I have read your article
"Unobtrusive JavaScript" its amazing [still there are points I don't get it
but still its amazing], frankly speaking I hardly understand someone else
code, but your way of explaining and getting to the point is fantastic.
Actually I got this sort of coding from this site "www.pxl8.com" very neatly
explained and to the point also. So I was also following the same pattern,
maybe I am wrong [well I am wrong as you told me].
Coming back to my own question... tell me this what do u mean by
* Don't make your sites dependent on JavaScript,
* especially not with non-existent protocols like "javascript".
I will test you script InshaAllah soon, and will get back to you soon. Cuz I
have a lot of question about how to do good coding and about DOM.
Thanks again,
S. F. Alim
-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org]On Behalf Of Christian Heilmann
Sent: Monday, August 15, 2005 2:01 PM
To: thelist at lists.evolt.org
Subject: Re: [thelist] DOM ol li listing issue, Please Help!!!
You are going about this the completely wrong way.
A solution to your issue:
Start with a server side fallback for the same functionality:
<a href="list.php" id="listcreate">create list</a>
(I will not do the PHP here...)
then add a JavaScript to do it client side, for example:
function makelists()
{
if(!document.getElementById ||
!document.createTextNode){return;}
var listtrigger=document.getElementById('listcreate');
if(!listtrigger){return;}
listtrigger.onclick=function()
{
var items=new Array('One','Two','Three','and so
on');
var newol=document.createElement('ol');
var newli;
for(var i=0;i<items.length;i++)
{
newli=document.createElement('li');
newli.appendChild(document.createTextNode(items[i]));
newol.appendChild(newli);
}
listtrigger.parentNode.insertBefore(newol,listtrigger.nextSibling);
return false;
}
}
window.onload=makelists;
Which is not really up-to-date JS (not using addEvent and so on, but
does the trick).
More:
http://www.onlinetools.org/articles/unobtrusivejavascript/
http://www.wait-till-i.com/index.php?p=104
--
Chris Heilmann
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/
Binaries: http://www.onlinetools.org/
--
* * 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