Jump to content

display list starting at updated record

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 post
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.


Link to post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...