473,383 Members | 1,855 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

scroll buttons for div

I'm trying to build a scrollable div with "up" and "down" buttons to
replicate the action of a scroll bar. The reason I'm not just using
"overflow:auto" is because I want to position the scroll buttons on the
LEFT side of the box.

Don't ask why, I'm not the client ;)

Anyway, I've managed to get this working on some browsers by modifying
the scrollTop property of the div object, but it seems that this is
actually supposed to be read-only, and is inconsistent in any event.

Any ideas for how to do this cleanly?

-J
Jul 23 '05 #1
1 7504
Jonathan wrote:
I'm trying to build a scrollable div with "up" and "down" buttons to
replicate the action of a scroll bar. The reason I'm not just using
"overflow:auto" is because I want to position the scroll buttons on the
LEFT side of the box.

Don't ask why, I'm not the client ;)

Anyway, I've managed to get this working on some browsers by modifying
the scrollTop property of the div object, but it seems that this is
actually supposed to be read-only, and is inconsistent in any event.

Any ideas for how to do this cleanly?

-J

If you put the contents inside two div tags you can use CSS to clip the
outer div and "scroll" the inner div by scripting its CSS "top" value, thus:

<html><head><style>
#contents{ position: relative; top: 0; left: 0; width: 100px; height: auto;}
#scrollable{ overflow: hidden; width: 100px; height: 100px; border: 1px
solid black;}
</style>
<script>
var t = 0;

function up()
{
t += 10;

with(document.getElementById("contents"))
{
if (t > 0)
t = 0;

if(style)
style.top = t + "px";
else
setAttribute("style", "top: " + t + "px");
}
}

function down()
{
t -= 10;

with(document.getElementById("contents"))
{
if(t < -clientHeight)
t = -clientHeight;

if(style)
style.top = t + "px";
else
setAttribute("style", "top: " + t + "px");
}
}
</script></head>
<body><table><tr><td><a href="javascript:void(0)"
onclick="up()">up</a></td><td rowspan="2"><div id="scrollable"><div
id="contents">scrolling content scrolling content scrolling content
scrolling content scrolling content scrolling content scrolling content
scrolling content scrolling content scrolling content scrolling content
</div></div></td></tr><tr><td><a href="javascript:void(0)"
onclick="down()">down</a></td></tr></table>
</body></html>
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Yaron C. | last post by:
Hi, I would like to ask for your help. Please look at the code below. I would like to keep the location of the buttons while scrolling to the right but I can't get a smoth scroll (without...
2
by: Joshua Moore | last post by:
Is there any way to have buttons scroll up and down on a standard textbox? The touchscreen we're using doesn't work very well on scroll bars, so I'd like to create buttons to immitate the Page Up /...
12
by: Jim H | last post by:
I have a ListBox hold a list of my custom controls (it's UserControl based control with a couple radio buttons and a checkbox). Everything works and displays the way I expected it to. I can move...
1
by: Dino M. Buljubasic | last post by:
I have two controls, a panel holding check boxes and a treeview beside the panel. I use buttons to scroll both of thes up and down at the same time but I'd like to make scroll bars on the...
0
by: memanwar | last post by:
Throughout our system we use the DataGrid. One problem we've noticed is that the arrow buttons don't always work with our grids, clicking on them sometimes won't move the columns at all, or may...
3
by: Joel Whitehouse | last post by:
Hello All, I am wondering how I can get a pair or usercontrol buttons that look like the ones on a horizontal scroll bar. I don't want a scrollbar really, just the buttons with the nifty little...
0
by: nevada17 | last post by:
My goal is to find a way to apply scroll bars across the y axis of about 25 check buttons so that my interface isn't too large. I've read about scroll bars and I realize that's its not possible to...
2
by: Steve | last post by:
Hi All I want to prevent the Windows Tabcontrol from showing the horizontal scroll bar when the Number of Tabs exceeds the width of the control I use code in 2 buttons to control the...
2
by: ryuujin | last post by:
Hi, sorry about my english. I need to scroll manually the content of a panel when the user click on a button. The user have to interact with my application by a touch screen monitor and I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.