Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scrollable DIV - jump to position problem 1

Status
Not open for further replies.

MakeItSo

Programmer
Oct 21, 2003
3,316
DE
Hi friends,

I have an ASP page which pulls data from a DB.
This data is then displayed in different areas:
One is a list of all (or filtered) entries, displayed in a scrollable DIV of fixed size, one is the detail DIV, where record details are displayed.
The list entries consist of links, which all look like this:
Code:
<div id="liste">
<p class="heading">Source</p>
<p class="current">my current record</p>
<a href=myasp.asp?recid=1>entry</a><br/>
<a href=myasp.asp?recid=2>another entry</a><br/>
...
</div>

If the user now clicks one of the entries, the page reloads, displaying this entry in the detail DIV.

My problem now is, that I wish to display the list of all entries at the position of the chosen entry.
I cannot use the Javascript "scrolltop" function, because one usually does not click the top entry of that list, and the resulting list order would therefore be confusing.

I tried with
Code:
rs.find "[recid]=" & recid
which displays the list in the DIV at the exact required position. Alas, in this case the user cannot scroll upwards of course!

I will include IDs to identify the position such as this:
Code:
<a href=myasp.asp?recid=1 ID="[red]<%=recid%>[/red]">entry</a><br/>

Any suggestions on how to best accomplish this feat?

Thanks a lot!

MakeItSo

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
i think you could try something in line with this:
Code:
<body onload=GotoEntry( {selected id} )>

<script language=javascript type="text/javascript">
    function GotoEntry(i) {
        var objDiv = document.getElementById("liste");
        objDiv.scrollTop = (objDiv.scrollHeight/ {no of enries in the list})*i;
    }
</script>

<div id="liste">
<p class="heading">Source</p>
<p class="current">my current record</p>
<a href=myasp.asp?recid=1>entry</a><br/>
...


Your script must fill in the {} values!
 
I knew it had to be simple!
I'll have to adapt my code a little and add another counting variable but that'll do just fine.

Thanks a lot!
[thumbsup2]

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top