iEntry 10th Anniversary Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Reply
 
LinkBack Thread Tools
Old March 15th, 2009, 05:23 AM   #1
New Member
 

Join Date: Mar 2009
Location: New Delhi
Age: 25
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 nishithkant is on a distinguished road
scrolling effect needed

please check this code .it works on up and down button but doesn,t scroll alongwith going down the records .please help me I want record go down and also be scroll.
<script language="JavaScript1.1" type="text/javascript">
var currentRow = 1;
var VISIBLE_ROWS = 10;

window.onload = function()
{
var table = document.getElementById('mytable' );
var trs = table.getElementsByTagName('tr');
highlightRow( trs[currentRow] );
}

var highlightedRow;




function addOnclickToDatatableRows()
{
var trs = document.getElementById('mytable').getElementsByTa gName('tr');
for (var i = 0; i < trs.length; i++)
{
trs[i].onclick = new Function("highlightRow(this)");
}
}

function highlightRow(tr)
{
tr.bgColor = (tr.bgColor != '#0000ff') ?'#0000ff' : '#ffffff';
highlightedRow = tr;
}

function dehighlightRow(tr)
{
tr.bgColor = (tr.bgColor != '#ffffff') ?'#ffffff' : '#0000ff';
table = null;
trs = null;
}


function processKeys(mytable,dir)
{

var table = document.getElementById('mytable' );
var numRows = table.rows.length;

switch (dir)
{

case 'u':
if (parseInt(currentRow) == parseInt(1))
{
// reached the top of the table; do nothing.
return true;
}
else
{
// move one row up.
scrollRow( "up" );
setCurrentRow( currentRow );
//highlightRow(currentRow);

return false;
}
break;

// Key down.
case 'd':
if (currentRow == (numRows - 1))
{
// reached the end of the table; do nothing
return true;
} else
{
scrollRow( "down" );
setCurrentRow( currentRow );
//highlightRow(currentRow);
if (currentRow > VISIBLE_ROWS)
{
return true;
} else
{
return false;
}
}
break;
}

function scrollRow( dir )
{
var trs = document.getElementById('mytable').getElementsByTa gName('tr');
if (dir == "up")
{
dehighlightRow ( trs[ currentRow ] );
currentRow--;
highlightRow( trs[ currentRow ] );
}
else if (dir == "down")
{
dehighlightRow( trs[ currentRow ] );
currentRow++;
highlightRow( trs[ currentRow ] );
}
}
function setCurrentRow ( currentRow)
{


if (dir == "up")
{

highlightRow( trs[currentRow] );
}
else if (dir == "down")
{

highlightRow( trs[currentRow] );
}


}



}

</script>

<style type="text/css">
.scrollbar
{
width:100px;
height:120px;
overflow:hidden;
}
</style>
</head>
<body>


<div class="scrollbar">
<table id="mytable">
<tr>
<td>
record1</td>
</tr>
<tr>
<td>
record2</td>
</tr>
<tr>
<td>
record3</td>
</tr>
<tr>
<td>
record4</td>
</tr>
<tr>
<td>
record5</td>
</tr>
<tr>
<td>
record6</td>
</tr>
<tr>
<td>
mridul7</td>
</tr>
<tr>
<td>
mridul8</td>
</tr>
<tr>
<td>
record9</td>
</tr>
<tr>
<td>
mridul10</td>
</tr>
<tr>
<td>
record11</td>
</tr>
<tr>
<td>
record12</td>
</tr>
<tr>
<td>
record13</td>
</tr>
<tr>
<td>
record14</td>
</tr>
<tr>
<td>
mridul15</td>
</tr>
<tr>
<td>
mridul16</td>
</tr>
<tr>
<td>
record17</td>
</tr>
<tr>
<td>
record18</td>
</tr>
</table>
</div>

<input type="button" id="btnUp" value="up" onclick="processKeys('mytable','u');" />
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" id="btnDown" value="Down" onclick="processKeys('mytable','d');" />
</body>
nishithkant is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Tags
button , onclick , scrooling , table


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help using 2 effect together... mauriziol JavaScript 1 July 17th, 2008 10:29 AM
Scrolling Photos Effect - How?? FXDesigns HTML, XHTML and CSS 9 January 24th, 2008 07:16 AM
scrolling! help! alexgeek The Café 5 August 8th, 2007 02:37 PM
What is this effect? papalazarou78 Flash and ActionScript 4 May 17th, 2007 04:17 PM
3D Side Scrolling noanswer42 Flash and ActionScript 4 July 29th, 2005 09:37 AM


Search Engine Optimization by vBSEO 3.2.0 RC8