Ensure there is no space following the conclusion of the scrolling div

I am working on displaying a series of divs one after another. The scrolling works smoothly, but once the last div goes off screen, there is a gap before the first div comes back in view. I want the first div to immediately follow the last div without any gaps in scrolling.

Here's my code:

<script type="text/javascript">

var delayb4scroll=1000
var marqueespeed=1
var pauseit=1 
var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee(){
  if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+1))
    cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"
  else
    cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
}

function initializemarquee(){
  cross_marquee=document.getElementById("vmarquee")
  cross_marquee.style.top=0
  marqueeheight=document.getElementById("marqueecontainer").offsetHeight
  actualheight=cross_marquee.offsetHeight
  if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ 
    cross_marquee.style.height=marqueeheight+"px"
    cross_marquee.style.overflow="scroll"
    return
  }
  setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll)
}

if (window.addEventListener)
  window.addEventListener("load", initializemarquee, false)
else if (window.attachEvent)
  window.attachEvent("onload", initializemarquee)
else if (document.getElementById)
  window.onload=initializemarquee
</script>

<div id="marqueecontainer" onmouseover="copyspeed=pausespeed" onmouseout="copyspeed=marqueespeed">
    <div id="vmarquee" style="position: absolute; width:243px;">
    <?php include 'viewdata.php';?>
    </div>

viewdata.php

    <?php    
    mysql_connect(gethostbyname(trim(`hostname`)) , ****, ****) or die ("Please check your server connection."); 
    mysql_select_db("****") or die("error");
    $query = "select * from table1";
    $result = mysql_query($query) or die (mysql_error());
    $num = mysql_numrows($result);
    $flags2=0;$flags=0;
    ?>
    <?php
    while($rows = mysql_fetch_array($result)) {
        $flags++;
    ?>
    <div class="marqueeElement" style="height:auto;width:220px;text-align:left;font-weight:normal;color: #BF5A14;font-size:70%;position:absolute;padding-left:10px;"> 
    <br><br><font style="font-weight:bold;color:#003399;">col 1 </font>
    <br><font style="font-weight:bold;color:#003399;">col 2 </font>         
</div>
<div style="height:150px;margin-left:-40px;color:#000000;font-weight:normal;">---------------------------------------------------<br></div>
    <?php } ?>
<font style="margin-left:-40px;color:#000000;font-weight:normal;">---------------------------------------------------</font>

The PHP script in viewdata.php fetches data from a database table and displays it within the div elements.

Answer №1

Below is the solution I found to eliminate any blank spaces on the page:

I made a simple modification to my viewdata.php file

viewdata.php

<?php    
mysql_connect(gethostbyname(trim(`hostname`)) , ****, ****) or die ("Unable to establish server connection."); 
mysql_select_db("****") or die("error");
$query = "select * from table1";
$result = mysql_query($query) or die (mysql_error());
$num = mysql_numrows($result);
$flags2=0;$flags=0;$temp=400;
?>
<?php
while($rows = mysql_fetch_array($result)) {
$flags++;   


 ?>
    <div class="marqueeElement" style="height:auto;width:220px;text-align:left;font-weight:normal;color: #BF5A14;font-size:70%;position:absolute;padding-left:10px;"> 
    <br><br><font style="font-weight:bold;color:#003399;">print col 1 </font>
    <br><font style="font-weight:bold;color:#003399;">print col 2 </font>         
</div>
<div style="height:150px;margin-left:-40px;color:#000000;font-weight:normal;">---------------------------------------------------<br></div>
    <?php } ?>

<?php 

//to start the loop if table have more than 3 rows 

if($num > 3) {

while($temp > 0) {
$temp--;
 $query2 = "select * from table1";
    $result2 = mysql_query($query2) or die (mysql_error());
    $num2 = mysql_numrows($result2);
 while($rows = mysql_fetch_array($result2)) {   ?> 

 <div class="marqueeElement" style="height:auto;width:220px;text-align:left;font-weight:normal;color: #BF5A14;font-size:70%;position:absolute;padding-left:10px;"> 
    <br><br><font style="font-weight:bold;color:#003399;">print col 1 </font>
    <br><font style="font-weight:bold;color:#003399;">print col 2 </font>         
</div>
<div style="height:150px;margin-left:-40px;color:#000000;font-weight:normal;">---------------------------------------------------<br></div>


<?php  } } } ?>



<font style="margin-left:-40px;color:#000000;font-weight:normal;">---------------------------------------------------</font>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

ajax requests getting blocked after doPostBack

When a user clicks on an anchor tag, I am prompting them to download a file. In the onclick event, I am using __doPostBack to perform a partial page postback and return the downloadable file to the user. The issue I am encountering is that if the file is ...

"Conceal navigation options in Angular JS depending on whether a user is logged in or

I am currently working on an Ionic app that has side menus with items like home, login, dashboard, and logout. For the login functionality, I am using a server API to authenticate users. When a user is logged in, I want the side menu items to display as f ...

Stop specific characters from being input into a text field

My goal is to restrict the characters allowed in a text box to the following: A to Z in both upper and lower case, Ñ and ñ, and space. I have a function that runs onkeyup: FieldOnKeyUp(el) { !(/^[A-zÑñ-\s]*$/i).test(el.value)?el.value = el.value ...

Receiving JSON output from nightwatch.js

Is it possible to execute a JSON object from an HTML ul list like this? {name: "Nick", surname:"Kyrgios", age: "22", city: "Sydney"}, {....}, {....} Here is the corresponding HTML code: <html> <ul> <li class="user"> <div class ...

Creating a custom form to generate a unique URL on a website

For instance, users on a platform like Craigslist can fill out a form specifying their requirements. Upon submission, the platform automatically generates a new URL hosted on its website. I am unsure of how this process works or what it is called. Can an ...

One convenient script to easily toggle fading effects

I've successfully implemented a slide toggle functionality that hides all toggle elements when clicking outside the buttons. However, I'm facing an issue where I need to create a separate script for each button to display and hide the tooltip/con ...

Stopping a function that is currently running on a website using Javascript

I have a script on my website that triggers a rain feature when a user clicks on a button. However, I am struggling to figure out how to allow the user to deactivate this feature. I've tried various methods such as using break, return, and timeouts, b ...

Having trouble aligning four chart JS charts perfectly within a div

I am facing an issue with my webpage layout. I have a side panel that takes up 25% of the page on the left side and a div on the right that takes up 75%. Within this right div, I have 4 ChartJS graphs arranged in a 2 by 2 format. Despite trying various m ...

Identifying and detecting Label IDs when clicked using the for tag

I am facing an issue with labels and input fields in my code. I have multiple labels that trigger the same input field, but I want to know which specific label triggered the input field. <label id="label1" for="input1">Document1</label> <la ...

Straightforward AngularJS widget implemented with a personalized Directive

Currently, I am diving into the world of AngularJS and it has been quite a rollercoaster ride. Today, I attempted to create a super simple test widget using AngularJS but unfortunately, I am struggling to get it to function properly. I have a feeling that ...

Achieve the positioning of a Bootstrap navbar within a div without it getting wrapped by following

I have been attempting to overlay my navbar on top of a background image by nesting it within a div and using absolute positioning. However, I've run into an issue where the navbar-header/navbar-brand section causes the rest of the navbar to wrap onto ...

AngularJS issue: Unable to reset scope variable

I am facing an issue with a function in my angularJS controller that is triggered on a dropdown option change: Currently, when a default option is selected, the corresponding records from the database are fetched and set to a scope variable. Everything s ...

Troubleshooting alignment problems with a responsive gallery (Bootstrap-gallery & justifyGallery)

Looking to showcase a gallery of images using jquery-justifyGallery and bootstrap-gallery. Want to display 4 images in a row, but running into issues when trying to display 5 images where the last image in the row ends up with a larger width. Bootstrap has ...

Save the Ajax "stack" variable to a text file rather than duplicating it

I have a question regarding posting variables to a .txt file. The variable in question is '10'. However, every time I post the variable, the .txt file simply keeps adding "10" instead of stacking it. Ideally, I want it to display 10 on the first ...

Is there a compatibility issue between Vue particles and my project?

Greetings to all! I recently added Vue Particle to my Vue project, but encountered an issue while importing VueParticles in the Main.js file. Here is a snapshot from my terminal for reference. https://i.stack.imgur.com/Bxh2r.png ...

Dynamic Bootstrap Table with Fixed Header

I am customizing a Bootstrap table by adding CSS for a sticky header. My code snippet includes the following: .table-sticky th { background: #fff; position: sticky; top: -1px; z-index: 990; } <div class ...

Iterate over various selection lists and tally the frequency of each option being chosen

I am currently working on a website that requires multiple instances of the same select-option to be created. I want to keep track of how many times each option is selected, and save that count as a variable to be used in a PHP email function. For instanc ...

left lower corner & right lower corner of the HTML element

Is there a way to retrieve the x-y coordinates for the bottom left and bottom right of an HTML element? I am interested in assigning this information to another <div></div> ...

Hold on submitting the form with jQuery until the checkbox has been ticked

Hey there, I've added some jQuery code to validate a checkbox on a specific form. You can see a simple example on my JSFiddle. However, even if the checkbox is not clicked, the form still submits, but the alert message shows up. I'm trying to pr ...

Personalized input element featuring integrated chips and accompanying text

I am in the process of designing a unique custom input element with dual functionality. It allows users to input text It enables users to embed or remove chips within the text by selecting an option from a dropdown menu My current development stack inclu ...