SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Displaying Links

    Can ne one tell me how to do this
    I want to write a link to a html
    page but i want to either use an
    array or functions to store the info,
    but it keeps coming up wrong with the
    second function not displaying or gets
    a clear space.

    <html>
    <head>
    <title>Home Page</title>
    </head>
    <body>
    <script>

    //=======================================function

    /*
    function spacer(){
    document.write(" | ");
    }
    function url(title,ref,word){
    url = "<a title="+title+" href=\""+ref+"\">"+word+"</a>";

    return url;

    }
    function home(){
    var title = "netroworld&nbsp;the&nbsp;home&nbsp;of&nbsp;the&nbsp;netro&nbsp;community";
    ref = "http:\\www.netroworld.net";
    word = "home";
    url = url(title,ref,word);

    return url;

    }
    function mysite(){
    var title = "mysite";
    ref = "http:\\www.mysite.net";
    word = "mysite";
    url = url(title,ref,word);

    return url;
    }

    document.write(home());
    spacer();
    document.write(mysite());
    spacer();
    */

    //=======================================Array

    var title = new Array();
    title[0] = "Home"
    title[1] = "links"
    title[2] = ""
    title[3] = ""
    title[4] = ""
    title[5] = ""
    title[6] = ""
    title[7] = ""
    title[8] = ""
    title[9] = ""
    title[10] = ""

    var ref = new Array();
    ref[0] = "http:\\www.home.net"
    ref[1] = "http:\\www.links.net"
    ref[2] = ""
    ref[3] = ""
    ref[4] = ""
    ref[5] = ""
    ref[6] = ""
    ref[7] = ""
    ref[8] = ""
    ref[9] = ""
    ref[10] = ""

    var word = new Array();
    word[0] = "home"
    word[1] = "links"
    word[2] = ""
    word[3] = ""
    word[4] = ""
    word[5] = ""
    word[6] = ""
    word[7] = ""
    word[8] = ""
    word[9] = ""
    word[10] = ""

    for (var i = 0;title[i]<=title[10];i++)
    {
    document.write("<a title="+title[i]+" href=\""+ref[i]+"\">"+word[i]+"</a>");
    spacer();
    }

    //document.write("<a title="+title[0]+" href=\""+ref[0]+"\">"+word[0]+"</a>");
    </script>
    </body>
    </html>

    can ne one help thanx

  2. #2
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Displaying Links

    for (var i = 0;title[i]<=title[10];i++)
    {
    document.write("<a title="+title[i]+" href=\""+ref[i]+"\">"+word[i]+"</a>");
    spacer();
    }

    //document.write("<a title="+title[0]+" href=\""+ref[0]+"\">"+word[0]+"</a>");
    </script>
    </body>
    </html>

    can ne one help thanx [/B]
    Make the for line look like this

    for (var i=0;i<title.length;i++){

    }

    Or if you know the length simply place the number in there

    for (var i=0; i<10 ; i++){

    }
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.


Bookmarks

Posting Permissions

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