SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    UK, London
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry scrolling through a table using javascript

    HELP NEEDED PLEASE!!!!!!

    The code below currently allows a user to view a table which is bigger than the division which it has been allocated, by scrolling up or down.
    I have added code to allow the user to scroll left or right, but its not working!!!!

    any ideas?

    Code:
    <div style="background-color:#FFFFDD;width:155"><center>
    <a href="javascript:movedown()">Lower</a><br />
    <a href="javascript:moveup()">Higher</a><br />
    <a href="javascript:moveright()">Right</a><br />
    <a href="javascript:moveleft()">Left</a><br />
    <a href="javascript:stopscroll()">Stop!!</a><br />
    <a href="javascript:movetop()">Top of the table</a><br /></center>
    </div>
    
    <SCRIPT language="JavaScript1.2">
    
    //specify speed of scroll (greater=faster)
    var speed=4
    
    iens6=document.all||document.getElementById
    ns4=document.layers
    
    if (iens6){
    document.write('<div id="container" style="position:absolute;width:1355;left:100;height:160px;overflow:hidden;border:4px ridge white">')
    document.write('<div id="content" style="position:absolute;width:1355;left:0;top:0">')
    }
    </script>
    
    <ilayer name="nscontainer" width=155 height=160 clip="0,0,155,160">
    <layer name="nscontent" width=155 height=160 visibility=hidden>
    
    <!-- CONTENT -->
    <table bgcolor="brown" border ="3" cellpadding="8" cellspacing="4">
    
    <tr><td>Customer Number</td>
    <td>0111 </td>
    <td>0111 </td>
    <td>0111 </td>
    <td>0111 </td>
    <td>0111 </td>
    <tr><td>Customer Borough </td>
    <td>islingtontesttest</td></tr>
    
    <tr><td>Customer City </td>
    <td>londontest</td></tr>
    
    <tr><td>Customer Postcode </td>
    <td>wc1a 3sktest</td></tr>
    </table>
    
    <!--END CONTENT-->
    
    </layer>
    </ilayer>
    
    <script language="JavaScript1.2">
    if (iens6){
    document.write('</div></div>')
    var crossobj=document.getElementById? document.getElementById("content") : document.all.content
    var contentheight=crossobj.offsetHeight
    var contentwidth=crossobj.offsetWidth
    }
    else if (ns4){
    var crossobj=document.nscontainer.document.nscontent
    var contentheight=crossobj.clip.height
    var contentwidth=crossobj.clip.width
    }
    
    function movedown(){
    if (window.moveupvar) clearTimeout(moveupvar)
    if (iens6&&parseInt(crossobj.style.top)>=(contentheight*(-1)+150))
    crossobj.style.top=parseInt(crossobj.style.top)-speed
    else if (ns4&&crossobj.top>=(contentheight*(-1)+100))
    crossobj.top-=speed
    movedownvar=setTimeout("movedown()",100)
    }
    
    function moveup(){
    if (window.movedownvar) clearTimeout(movedownvar)
    if (iens6&&parseInt(crossobj.style.top)<=0)
    crossobj.style.top=parseInt(crossobj.style.top)+speed
    else if (ns4&&crossobj.top<=0)
    crossobj.top+=speed
    moveupvar=setTimeout("moveup()",100)
    }
    
    function moveright(){
    if (window.moveleftvar) clearTimeout(moveleftvar)
    if (iens6&&parseInt(crossobj.style.top)>=(contentwidth*(-1)+100))
    crossobj.style.top=parseInt(crossobj.style.top)-speed
    else if (ns4&&crossobj.top>=(contentwidth*(-1)+200))
    crossobj.top-=speed
    moverightvar=setTimeout("moveright()",100)
    }
    
    function moveleft(){
    if (window.moverightvar) clearTimeout(moverightvar)
    if (iens6&&parseInt(crossobj.style.top)<=0)
    crossobj.style.top=parseInt(crossobj.style.top)+speed
    else if (ns4&&crossobj.top<=0)
    crossobj.top+=speed
    moveleftvar=setTimeout("moveleft()",100)
    }
    
    function stopscroll(){
    if (window.moveupvar) clearTimeout(moveupvar)
    if (window.movedownvar) clearTimeout(movedownvar)
    if (window.moverightvar) clearTimeout(moverightvar)
    if (window.moveleftvar) clearTimeout(moveleftvar)
    }
    
    function movetop(){
    stopscroll()
    if (iens6)
    crossobj.style.top=0
    else if (ns4)
    crossobj.top=0
    }
    
    function getcontent_height(){
    if (iens6)
    contentheight=crossobj.offsetHeight
    else if (ns4)
    document.nscontainer.document.nscontent.visibility="show"
    }
    window.onload=getcontent_height
    
    /* function getcontent_width(){
    if (iens6)
    contentwidth=crossobj.offsetWidth
    else if (ns4)
    document.nscontainer.document.nscontent.visibility="show"
    }
    window.onload=getcontent_width
    */
    If you can talk, you can sing, if you can walk, you can dance!!

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Learn css and Javascript!!!!

    It really annoys me when people do this - no offense.

    Your functions still refer to how to move the vertical proportions of the object.
    The references - if you look - are to style.top!!!

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    UK, London
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Flawless-you have such a way with words!!!
    If you can talk, you can sing, if you can walk, you can dance!!

  4. #4
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After your pm i guess i can afford more time on this for you.
    But i first must really ask this:

    Do you actually know JS and are you familliar with CSS?

    Thanks

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    UK, London
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have now managed to get my table to scroll in both directions :-)

    in regards to your question :
    Do you actually know JS and are you familliar with CSS?
    By JS and CSS i guessing you mean Javascript and Cascading Style Sheets???

    My strength is actually in COBOL, but i have been working on projects using HTML for three years, and Java since Christmas. The project I am currently working on needed some "JS", and so i went about researching what i needed to know via (1) other members of my team (2) this site, and (3)books.

    I am (like most people), learning more every day. I thought this site was for (amongst other things), people who wanted to improve/share their knowledge within a particular area, which is why i posted the code.

    Flawless, all I can say to your comments are...either you want to help me or you dont!....no offence will be taken, whichever you decide :-)

  6. #6
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Flawless_koder
    Learn css and Javascript!!!!

    It really annoys me when people do this - no offense.
    Do what? Ask questions? Try to teach themselves? Learn?

    Or be an *** to others?

    cjdesigns...you've come to the right place for questions about web design. Welcome.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  7. #7
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh no - i was definately planning on helping you.
    I always will if someone goes to the effort
    of sending me a personal message. It just seemed
    strange that bits of the functions had remained untouched.

    I'm glad you've got it fixed - and if you get any more problems ask away - i'll be amicable enough

    btw - i DID point to where your problem was - i wouldn't bother posting without giving some hint of where the problem was.

    What do you work on in cobol, and what compiler camp are you from?
    My company's main product is a HUGE cobol program turned to web using Mason/perl and a daemon system - it works well.
    I don't trust the cobol web system - it goes about things the wrong way.

    Good luck with your work

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  8. #8
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    UK, London
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    to Creole :-
    cjdesigns...you've come to the right place for questions about web design. Welcome.
    Thank you!!!


    To 'Flawless' :-
    The reason why I sent you a private message was to stop this thread turning into a 'i-am-going-to-throw-an-insult' session. I also wanted to make sure that i had interpreted (what i had first thought was quite a rude reply), correctly.

    Yes, your right, you did point me in the right direction, so thank you. However, reading back on some of the other posts you have made within sitepoint, I think you need to take a few moments to reflect on the impression you give others when you use such an abrasive style to respond to posts

    kind regards
    christina
    If you can talk, you can sing, if you can walk, you can dance!!


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
  •