alphabetable

liunx

Guest
Hi<br />
<br />
Does anyone know, is it possible to get a column of links in a table in alphabetical order without manually cutting and pasting? Is there a command which might be able to achieve such an effect?<br />
<br />
thanks<!--content-->You would probably have to do that with Java Script.<!--content-->If the links are in an array you can use the array.sort() command in JavaScript and then create the table.<!--content-->ah, thanks, i will try that<!--content-->so, something like this inside the HEAD tags... <br />
i know this isn't complete, can anyone help me make it work? What I want is to be able to sort the links into alphabetical order whenever a new one is added to the table.<br />
<br />
<SCRIPT type="text/javascript"><br />
link=new Array()<br />
link[1]="http://www.landrover.com/gb/en/default.htm"<br />
link[2]="http://www.lpga.co.uk/LPGA.htm"<br />
link[3]="http://haynes.co.uk/"<br />
link[4]="http://www.merlin.cardiff.landrover.co.uk/"<br />
link[5]="http://offroadwales.co.uk/"<br />
link[6]="http://www.cardiff4x4club.co.uk/"<br />
link[7]="http://www.bearmach.com/"<br />
link[8]="http://www.aber4x4parts.co.uk/"<br />
link[9]="http://www.cowbridgetown.co.uk/owenmotors.htm"<br />
link[10]="http://www.wickvancentre.co.uk/"<br />
num=0<br />
function array.sort() <br />
<br />
</SCRIPT><!--content-->Try this:<script type="text/javascript"><br />
//<![CDATA[<br />
var myLinks = [<br />
'landrover.com/gb/en/default.htm',<br />
'lpga.co.uk/LPGA.htm',<br />
'haynes.co.uk/',<br />
'merlin.cardiff.landrover.co.uk/',<br />
'offroadwales.co.uk/',<br />
'cardiff4x4club.co.uk/',<br />
'bearmach.com/',<br />
'aber4x4parts.co.uk/',<br />
'cowbridgetown.co.uk/owenmotors.htm',<br />
'wickvancentre.co.uk/'<br />
];<br />
myLinks.sort();<br />
document.writeln('<h1>Sorted links</h1><ul>');<br />
for(i=0; i<myLinks.length; i++)<br />
{<br />
myLinks = 'http://www.' + myLinks;<br />
document.writeln('<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"' + myLinks + '">' + myLinks + '</a></li>');<br />
}<br />
document.writeln('</ul>');<br />
//]]><br />
</script>However, I wouldn't recommend generating content with JavaScript since it will become inaccessible to 13% of your users. Only use this if you know your users have browsers in which support JavaScript and have it enabled. A good example of this is if this is for an intranet where you would know what browsers, browser versions, JavaScript support and operating systems your users would have.<!--content-->Originally posted by fredmv <br />
However, I wouldn't recommend generating content with JavaScript since it will become inaccessible to 13% of your users. Only use this if you know your users have browsers in which support JavaScript and have it enabled. A good example of this is if this is for an intranet where you would know what browsers, browser versions, JavaScript support and operating systems your users would have. [/B] Yes it is not good to realy on any form of client side scripting because many users do not support it and then there is the fact that it is going to add noticable lag to your site, its just more bandwidth, and furthermore it is not secure and if your site is using passwords or has sensative data it will leave you as open as your source code is to hackers. Java script is rarely a viable option but if you do not have access to a server side language or are new to webdesign and do not know one yet just know java scripts limitations and have a backup plan for users who do not support it.<!--content-->
 
Back
Top