SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: JavaScript Help

  1. #1
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JavaScript Help

    Hi I have some simple html that I would like to sort using JavaScript. I'm new to this so I apologise in advance for my inexperience.

    <html>
    <head>
    A-Z List
    </head>

    <body>

    <script type="text/javascript">
    </script>

    <ul class="atozUl">
    <li>Copyright</li>
    <li>Council - spending plans - consultation</li>
    <li>Data protection</li>
    <li>Digital Region</li>
    <li>Freedom of information</li>
    <li>Libraries - online information resources</li>
    <li>Our Standards</li>
    </ul>

    </body>

    </html>

    I would like it output so that the first 3 bullet points in the list output on the left of the page, second three in the middle and the final two on the right hand side using JavaScript.

  2. #2
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It sounds like you're trying to lay out your page using JavaScript. Please research CSS, that's what it's for.

  3. #3
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes i need it working in JavaScript, got working in CSS already and it out puts it like.

    1.bullet point 1 2. bullet point 2 3.bullet point 3
    4.bullet point 4 5. bullet point 5 6.bullet point 6
    7.bullet point 7 8. bullet point 8

    however I want it to out put it

    1.bullet point 1 4.bullet point 4 7.bullet point 7
    2.bullet point 2 5.bullet point 5 8.bullet point 8
    3.bullet point 3 6.bullet point 6

  4. #4
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Create 3 columns and put your elements in there. No JavaScript necessary. Until most browsers implement text columns natively, this is your best bet. Besides, if JavaScript is disabled, most people will see the layout as you have it right now with CSS.

  5. #5
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,598
    Mentioned
    411 Post(s)
    Tagged
    7 Thread(s)
    There are quite a few JavaScript solutions for columns, such as this one and this one. You'll find plenty more if you google columns with JavaScript.

  6. #6
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    any of you got any code? im a beginner and not too confident

  7. #7
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,598
    Mentioned
    411 Post(s)
    Tagged
    7 Thread(s)
    Have a look at the code on the pages I posted. They give some instructions for usage, so try it out and then post back when you hit a snag.

  8. #8
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi, tried it out but can't seam to get it to work

  9. #9
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,598
    Mentioned
    411 Post(s)
    Tagged
    7 Thread(s)
    Quote Originally Posted by swfc4lyf View Post
    hi, tried it out but can't seam to get it to work
    OK, that's understandable. Now, the best way to make use of a forum is to post your attempts—preferably as a live link—and then people can suggest what to try next. That way people get to help out and you learn in the process. Otherwise you are asking for someone to do the whole lot for you, which people really should be paid for.

    So, preferably post a link of what you have done so far, or at least the code you have tried (preferably as a full page with CSS in the head).

  10. #10
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I have so far:


    Code:
    <script type="text/javascript">
    
    var colOne = new Array("<li>Copyright</li>", "<li>Council - spending plans - consultation</li>", "<li>Data protection</li>");
    var colTwo = new Array("<li>Digital Region</li>", "<li>Freedom of information</li>", "<li>Libraries - online information resources</li>");
    var colThree = new Array("<li>Our standards</li>", "<li>Test</li>");
    
    
    //document.write(colOne);
    //document.write(colTwo);
    //document.write(colThree);
    for (i = 0; i < 3; i++)
     { document.write(colOne[i]);
       if (i < 3)
        document.write("");
     }
    
    
    
    </script>
    I want it to output the other two arrays at the side of the current so that it looks as though it is 3 columns


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
  •