Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    fiz
    fiz is offline
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Ticker Box / Scroller slides

    Hi People,

    I'm quite new to PHP and am abit stuck. I have got a Ticker box/ scroller that is working. The Ticker Box has 10 fixed slides which loop fine however if i leave one slide empty i end up with a large blank space before it goes back to the first slide. I would like to tell the script to go back to the first slide after the last populated slide. Any suggestion on how i can do this will be much appreciated.

    Please see code below:

    <html><head>
    <title>News Feed</title>
    <style type="text/css">
    body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    color:#616161;
    font-family:Arial,Helvetica,sans-serif;
    font-size:12px;
    background-color:e6f2f5;
    }

    #NewsDiv { position: absolute; left: 0; top: 0; width:480px; text-align:left; padding-left:15px; padding-right:15px;}


    a {
    font-family:Arial,Helvetica,sans-serif;
    color: #00a4b5;
    font-size:12px;
    text-decoration:underline;
    }

    a:hover {
    font-family:Arial,Helvetica,sans-serif;
    color: #00a4b5;
    font-size:12px;
    text-decoration:none;
    }

    h1 {
    margin-top:0px;
    margin-bottom:20px;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: normal;
    font-size:23px;
    line-height:23px;
    }

    h2 {
    margin:0px;
    font-family: Arial, Helvetica, sans-serif;
    color:#5e5e5e;
    text-align: left;
    font-weight:200;
    font-size:18px;
    line-height:18px;
    }

    h3 {
    margin:0px;
    padding-top:13px;
    font-family: Arial, Helvetica, sans-serif;
    color: #00a4b5;
    }

    .h1 {
    font-size: 2.3em;
    }

    .h2 {
    font-size: 18px;
    color: #842b37;
    margin-bottom:4px;
    line-height:20px;
    }

    .brown {color: #842b37;}

    .h3 {
    font-size: 18px;
    color: #00a4b5;
    width:190px;
    line-height:28px;
    margin-bottom:10px;
    border-bottom: 1px solid #00a4b5;
    }

    .bold {font-size: 130%; font-weight:bold;}

    </style>

    </head>



    <BODY onMouseover="scrollspeed=0" onMouseout="scrollspeed=current" OnLoad="NewsScrollStart();">

    <div id="NewsDiv"><br>

    <h2 class="brown">What's New:</h2>

    <?php $lcms_item_filename = 'news_scroller.txt'; ?>
    <?php $from_here_to_top_level = './'; // Relative path to top level dir ?>
    <?php $rel_path_to_lcms_area='./user_controlled_lcms_area'; // From top level dir ?>
    <?php require($from_here_to_top_level.$rel_path_to_lcms_area."/core_snippet_code.php"); ?>

    </div>


    <!-- YOU DO NOT NEED TO EDIT BELOW THIS LINE -->




    <script language="JavaScript" type="text/javascript">
    <!-- HIDE CODE


    var scrollspeed = "1" // SET SCROLLER SPEED 1 = SLOWEST
    var speedjump = "30" // ADJUST SCROLL JUMPING = RANGE 20 TO 40
    var startdelay = "3" // START SCROLLING DELAY IN SECONDS
    var nextdelay = "0" // SECOND SCROLL DELAY IN SECONDS 0 = QUICKEST
    var topspace = "0px" // TOP SPACING FIRST TIME SCROLLING
    var frameheight = "130px" // IF YOU RESIZE THE WINDOW EDIT THIS HEIGHT TO MATCH


    current = (scrollspeed)


    function HeightData(){
    AreaHeight=dataobj.offsetHeight
    if (AreaHeight==0){
    setTimeout("HeightData()",( startdelay * 1000 ))
    }
    else {
    ScrollNewsDiv()
    }}

    function NewsScrollStart(){
    dataobj=document.all? document.all.NewsDiv : document.getElementById("NewsDiv")
    dataobj.style.top=topspace
    setTimeout("HeightData()",( startdelay * 1000 ))
    }

    function ScrollNewsDiv(){
    dataobj.style.top=parseInt(dataobj.style.top)-(scrollspeed)
    if (parseInt(dataobj.style.top)<AreaHeight*(-1)) {
    dataobj.style.top=frameheight
    setTimeout("ScrollNewsDiv()",( nextdelay * 1000 ))
    }
    else {
    setTimeout("ScrollNewsDiv()",speedjump)
    }}



    // END HIDE CODE -->
    </script>


    </body>
    </html>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Not a PHP issue, nor a Java issue. Moving from Java forum to javascript forum.
    Also, in the future please wrap code in [code][/code] or [php][/php] to preserve the formatting.

  • Users who have thanked Fou-Lu for this post:

    fiz (11-06-2012)

  • #3
    fiz
    fiz is offline
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you Fou-Lu

  • #4
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,511
    Thanks
    3
    Thanked 504 Times in 491 Posts
    Code:
    function ScrollNewsDiv(){
     dataobj.style.top=parseInt(dataobj.style.top)-(scrollspeed)+'px';
     if (parseInt(dataobj.style.top)<AreaHeight*(-1)) {
      dataobj.style.top='0px';
      setTimeout("ScrollNewsDiv()",( nextdelay * 1000 ))
     }
     else {
      setTimeout("ScrollNewsDiv()",speedjump)
     }
    }
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Tags for this Thread

    Posting Permissions

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