Scrollbar and Page Refreshing

liunx

Guest
Hi everybody. This is my first time posting for help on the Internet for help with any of my coding. Here goes:<br />
<br />
I have a large table with several rows (128) that is too big to fit on one page, so I have a vertical scrollbar. Each of these rows has a button on it to Enable/Disable the item in the row when that button is pressed. When the button is pressed, the text displayed within it changes based on the state of the item in the row (e.g. Enabled -> Disabled).<br />
The problem I have is, if the user scrolls down, to say item #110, and then presses the button to change the state, the list refreshes (so that the button's text can change) to the top of the list: so that item #1 is at the top, and the scrollbar is returned to the very top.<br />
Is there a way to save the user's position in the scrollable list, so that when it refreshes, it is in the same place again before the user clicked the button?<br />
<br />
I have seen where if you scroll down on a long page, click to navigate to another page, and then click Back to the previous page, you will be returned to the same position you had scrolled to previously. I think this must just be a feature inherent in the browser. However, this is the functionality that I want.<br />
Any help with this would be GREATLY appreciated!!<br />
<br />
Thanks,<br />
Andy<!--content-->It depends how your enable/disable function is set up.<br />
You could conceivably create hash marks by each line and via javascript redirect to the appropriate link.<br />
<br />
If the update is done via a 3rd party server side script you may be out of luck unless you can change the script.<!--content-->kdjoergensen,<br />
What did you mean by "You could conceivably create hash marks by each line and via javascript redirect to the appropriate link."?<br />
Would the page be able to retain the state the scrollbar was in previously, and then redirect to the correct position after a button is pressed?<br />
<br />
I think I may be in the 'out of luck' category. I tried to break up the large scrollbar into several pages without scrollbars, with "reference buttons" at the bottom in a separate frame that when pressed, navigated the main frame to a certain spot in the list. But, the way my script is set up, when a button is pressed, the whole list is refreshed (via a database query) and the first item in the list is displayed again at the top, no matter what page the user was on.<br />
I also tried creating page up / page down buttons, but I don't know how to create and use a variable that will store the position my large list is in (i.e. which record is listed at the top after a page up / page down).<br />
<br />
Anyone have any other ideas?<!--content-->An example from a list (could equally be inside a <tr> element instead). This code goes on each line of the page, with an incrementing number for the next entry:<br />
<br />
<li><a name="123">123</a>: user data stuff and text here </li><br />
<br />
You can then jump to any line of the page by using a URL page reference like datapage.htm#123 from another page, or by just #123 from the same page, noting that you don't actually have to have any text inside the target anchor, if you don't need it.<br />
<br />
A clickable link that would take you to that line could be:<br />
Go to Line <a href=http://www.htmlforums.com/archive/index.php/"#123">123</a><br />
<br />
<br />
<br />
<br />
<br />
Edited for major typos<!--content-->another thing is to have the user change all of the ones he wanted then have them push the enable button. sure it will refresh but all of the ones they wanted changed would be done already.<br />
<br />
or, if this is done with querying a db, then you could set it so the very last # they checked would be saved in the POST and then have what giz said with the links, and then have the code go straight to it.<!--content-->giz,<br />
That sounds like what I want to do? I'm just not sure what is going on.<br />
<br />
Here is the code I tried (within my table):<br />
<%pos = rs.Fields("F_NUM").Value%><br />
<td> <table border="0" cellspacing="0" cellpadding="0" align="center" valign="center" height="40" width="125" class="button<%if (Server.HTMLEncode(rs.Fields("ENABLED").Value)="False" and Server.HTMLEncode(rs.Fields("FAILED").Value="True")) then %>_dead<%end if %>" style="padding:0,0,0,0"><br />
<td align="center" bgcolor="#<%=buttonbg%>" class="fault_text" onClick="<% if Session("Using_IOS") and not dead and not (Server.HTMLEncode(rs.Fields("ENABLED").Value)="False" and Server.HTMLEncode(rs.Fields("FAILED").Value="True"))then %>window.navigate('tfis_admin_whole.asp?myco=<% response.write myco %>&Fault_Code=<%=rs.Fields("F_NUM").Value%>&Fault_Number=<%=rs.Fields("FG_CODE").Value%>&name=<%=pos%>')<% end if %>"><font face="Arial" size="5"><%=mybu%></font><br />
<a name="<%response.Write(pos)%>"></a></td><br />
</td></table><br />
<br />
That code doesn't do anything, but it at least loads the page. I'm not sure where to put the href part in, and how that actually works. Also, I don't know if I put the "a name" part in the right place? I just tried to stick in in the code for the button, so that it would run when the button is pressed. F_NUM is a unique value for each row, so I thought I would use that as my counter (123 in your example).<!--content-->the <a name> would go right before each and everyone of you buttons. the name would equal the button id that it is enableing.<!--content-->Thanks for the help everyone, but I couldn't get the code to work leaving all of it in one file.<br />
I ended up breaking the list up into 12 asp files, with each of the pages displaying 11 records of the 128. Then I was able to add in a row at the bottom of each page to cycle through Next, Previous, Beginning, and End. Then when the user presses Enable/Disable, it Enables or Disables that specific line, and refreshes only that page of 11 records (so it appears to the user that the page isn't refreshing at all - just the button text & color changes). This works okay, but it's bad design, because if I ever have to change something with the way this works, I'll have to change it 12 times (copy/paste might help a little bit).<!--content-->
 
Back
Top