Jump to content

display list starting at updated record


Gilbert

Recommended Posts

Hi all,   I have a list anywhere from 10 to 100 items retrieved from a database table using php & sql via an XMLHttpRequest.   The list shows 5 or 6 records at a time in the screen view (phone) and you scroll thru them.  I have an edit button included with each record which triggers an overlay to change that record - then you click OK and it updates the info in the database table.   Then I show the list and the changes have taken place, but what I would like to do is show the list from just where the edit occurred, instead of the user having to scroll down maybe 50 or 60 records to confirm that it has changed.   I want ALL the records there but just to start at the one that was edited.   I have the unique ID of the table record and I think I should be able to use that to indicate where I want to start the listing, but I'm not sure how to go about implementing it.   I hope I explained it well enough - any ideas?   I've looked at several sites and haven't seen exactly what I want.   Thanx for responses!

PS  I think once the list has rendered on the screen, what I need is a gotoRecord command to scroll down automatically or something like that.  I might also add that the reason for wanting to do this is that the user will probably be changing a few records in approximately the same area of the list so it would save a lot of scrolling back and forth.  Thanx

Edited by Gilbert
more thoughts
Link to comment
Share on other sites

If you want to do it just with HTML, then use an anchor in the URL that you redirect them back to to tell the browser where to scroll to.  If you want to use Javascript, get the coordinates of the element that you want and use scrollTo to go there.

https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo

Link to comment
Share on other sites

Thank you so much justsomeguy!!  I decided on the HTML element.scrollIntoView because I already had the ID of the list item.   I said I had used php & sql to create the list so I just added a unique id attribute to the output wrapper and then used that as my element to scroll to.  It works perfectly!  I don't know why I didn't find this sooner - it's kind of weird that sometimes you have to know exactly what you want to find in order to search for it.   Ah well, thanx again!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...