Solved

scroll mini html table vertically

Posted on 2014-01-10
2
1,038 Views
Last Modified: 2014-01-13
I have a web page that data scrolls up and down I also need a page that scrolls data vertically
I have a plugin http://wmh.github.io/jquery-scrollbox/ that shows right to left and left to right is what I want but I insert code and data doesn't move.I need >>>>>>>>>>>> then <<<<<<
 The website displayed this to scroll left to right or Left direction: 'h',
  distance: 140,
  queue: 'demo6-queue'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>NBA GAME LOG</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jquery.scrollbox.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$.ajax({
		url: 'nba.xml',
		dataType: "xml"
	}).done(function(data) {
		$('game', data).each(function(i, game) {
			newGame = $('#gameTemplate').clone().removeAttr('id');
			
			$('.awayLogo', newGame).html( $('<img>').attr('src', 'http://powerzsoftware.com/nbalogos/' + $('vteamid', game).text() + '.png') );
			$('.awayTeam', newGame).html( $('vteam', game).text() );
			$('.awayScore', newGame).html( $('vscore', game).text() );

			$('.homeLogo', newGame).html( $('<img>').attr('src', 'http://powerzsoftware.com/nbalogos/' + $('hteamid', game).text() + '.png') );
			$('.homeTeam', newGame).html( $('hteam', game).text() );
			$('.homeScore', newGame).html( $('hscore', game).text() );

			$('.gameStatus', newGame).html( $('status', game).text() );
var newLink = $('<a>')
    .attr('href', 'http://dev.sportsnetwork.com/aspdata/nba2/Default.aspx?gameID=' + $('game_id', game).text() )
    .text( $('status', game).text() );

$('.gameStatus', newGame).html( newLink );
			$('#games ul').append( $('<li>').append(newGame) );
		});
		
		$('#games').scrollbox({
			
});

	});
});



</script>
<style type="text/css" media="screen">
#games {
	width: 225px;
	height: 400px;
	overflow: hidden;
}
#games {
	width: 365px;
	height: 300px;
	overflow: hidden;
	background-color: #FF9;
}
#games ul { padding: 0px; list-style-type:none; }

	#gameTemplate { display:none; }
	.gameLog { width: 222px; border-collapse:collapse; margin-bottom: 10px; }
	.gameLog td { text-align: center;  border: }
	.gameLog col:nth-child(1) { width: 50px; }
	.gameLog col:nth-child(2) { width: 155px;  }
	.gameLog col:nth-child(3) { width: 32px; }	
	.awayLogo img, .homeLogo img { width: 32px; height: 32px; }


#listing {
	position: absolute;
	width: 370px;
	height: 416px;
	z-index: 15;
	left: 382px;
	top: 8px;
}
</style>
</head>

<body>
		
<div id="games">
	<ul></ul>
</div>
<p><img src="http://dev.sportsnetwork.com/aspdata/Gamescast/Images/TSN.png" width="200" height="150"><img src="http://dev.sportsnetwork.com/aspdata/Gamescast/Images/insideNBA.png" width="200" height="150"></p>
<table id="gameTemplate" class="gameLog">
  <colgroup><col><col><col></colgroup>
	<tr>
		<td class="awayLogo"></td>
		<td class="awayTeam"></td>
		<td class="awayScore"></td>
	</tr>
	<tr>
		<td class="homeLogo"></td>
		<td class="homeTeam"></td>
		<td class="homeScore"></td>
	</tr>
	<tr>
		<td colspan="3" class="gameStatus"></td>
	</tr>
</table>
		
</body>
</html>

Open in new window

NBA.xml
jquery.scrollbox.js
DailyNBA.html
0
Comment
Question by:powerztom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 39772404
If I understand correctly and you want to change vertical to horizontal scrolling, what you need to do (looking at their example), is make sure the list items are beside each other and the ul is wide enough.

Try this in the css:
#games {
	/*width: 100%;*/
	width: 666px;
	height: 140px;
	overflow: hidden;
	background-color: #FF9;
}
#games ul { padding: 0px; list-style-type:none; }
#games ul li { display: inline-block; height: 100px; width: 222px; }

Open in new window

and change your scrollbox() call to:
		$('#games ul').css('width', (222 * $('#games ul li').length)+'px');
		$('#games').scrollbox({
			direction: 'h',
			distance: 222,
			delay: 1
		});

Open in new window

The 'queue' is a special option where new items are added dynamically. This could be needed if the xml file gets updated but might not be easily combined with the next point which I decided to have a go at.

If you want to ping-pong left and right as you described then some more code is needed. Note that in this code I also decided to define the number of items next to each other (tableWidth = 3), using it to set the width of the div dynamically and also using it to decide when to start moving backward.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>NBA GAME LOG</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jquery.scrollbox.js"></script>
<script type="text/javascript">

var tableLength, tablePos = 0, tableWidth = 3, tableTriggerDirection = 1;

$(document).ready(function() {
  $.ajax({
    url: 'nba.xml',
    dataType: "xml"
  }).done(function(data) {
    $('game', data).each(function(i, game) {
      newGame = $('#gameTemplate').clone().removeAttr('id');
      
      $('.awayLogo', newGame).html( $('<img>').attr('src', 'http://powerzsoftware.com/nbalogos/' + $('vteamid', game).text() + '.png') );
      $('.awayTeam', newGame).html( $('vteam', game).text() );
      $('.awayScore', newGame).html( $('vscore', game).text() );

      $('.homeLogo', newGame).html( $('<img>').attr('src', 'http://powerzsoftware.com/nbalogos/' + $('hteamid', game).text() + '.png') );
      $('.homeTeam', newGame).html( $('hteam', game).text() );
      $('.homeScore', newGame).html( $('hscore', game).text() );

      $('.gameStatus', newGame).html( $('status', game).text() );

      var newLink = $('<a>')
      .attr('href', 'http://dev.sportsnetwork.com/aspdata/nba2/Default.aspx?gameID=' + $('game_id', game).text() )
      .text( $('status', game).text() );

      $('.gameStatus', newGame).html( newLink );
      $('#games ul').append( $('<li>').append(newGame) );
    });

    tableLength = $('#games ul li').length;
    $('#games').css('width', (222 * tableWidth)+'px');
    $('#games ul').css('width', (222 * tableLength)+'px');
    
    $('#games').scrollbox({
      direction: 'h',
      distance: 222,
      autoPlay: false
    });

    setInterval(function () {
      $('#games').trigger(tableTriggerDirection == 1 ? 'forward' : 'backward');
      tablePos += tableTriggerDirection;
      if (tablePos == 0 || tablePos == tableLength - tableWidth) {
        tableTriggerDirection = -tableTriggerDirection;
      }
    }, 1000);

  });
});

</script>
<style type="text/css" media="screen">
#games {
  height: 120px;
  overflow: hidden;
  background-color: #FF9;
}
#games ul { padding: 0px; list-style-type:none; }
#games ul li { display: inline-block; height: 100px; width: 222px; }

  #gameTemplate { display:none; }
  .gameLog { width: 222px; border-collapse:collapse; margin-bottom: 10px; }
  .gameLog td { text-align: center;  border: }
  .gameLog col:nth-child(1) { width: 50px; }
  .gameLog col:nth-child(2) { width: 155px;  }
  .gameLog col:nth-child(3) { width: 32px; }	
  .awayLogo img, .homeLogo img { width: 32px; height: 32px; }


#listing {
  position: absolute;
  width: 370px;
  height: 416px;
  z-index: 15;
  left: 382px;
  top: 8px;
}
</style>
</head>

<body>
    
<div id="games">
  <ul></ul>
</div>
<p><img src="http://dev.sportsnetwork.com/aspdata/Gamescast/Images/TSN.png" width="200" height="150"><img src="http://dev.sportsnetwork.com/aspdata/Gamescast/Images/insideNBA.png" width="200" height="150"></p>
<table id="gameTemplate" class="gameLog">
  <colgroup><col><col><col></colgroup>
  <tr>
    <td class="awayLogo"></td>
    <td class="awayTeam"></td>
    <td class="awayScore"></td>
  </tr>
  <tr>
    <td class="homeLogo"></td>
    <td class="homeTeam"></td>
    <td class="homeScore"></td>
  </tr>
  <tr>
    <td colspan="3" class="gameStatus"></td>
  </tr>
</table>
    
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:powerztom
ID: 39776764
The page you made works great ping pong is really cool by boss wants a arrow to leftside and arrow to right side and if you click that arrow button games scroll in that direction. I should have mentioned that but this code works great I'll put in a new ticket with image and arrows great work here you never disappoint Rob.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question