Quick Base Discussions

Expand all | Collapse all

Return to previous location on a form after running a JAVA Script code and record refresh

  • 1.  Return to previous location on a form after running a JAVA Script code and record refresh

    Posted 10-30-2017 15:54
    I have a rather long form with multiple sections to organize 500+ data fields. When I click on a URL button that runs JAVA Script code to create child table records, update data fields in the main record, etc. and then refresh the main record, the form control goes to the beginning of the form. Is there any way I can redirect the control to the previous location on the form? I have tried the same with multiple tabs and it goes back to the first tab after update/refresh.


  • 2.  RE: Return to previous location on a form after running a JAVA Script code and record refresh

    Top
    Contributor
    Posted 10-30-2017 16:26
    Here is a how you get the page refresh to put you into a section.

    It is a two step process.

    (1) Insert a text element to your form, in the section you want the reload to go. 
    I will call it 'MySection'.
    The text element needs to be the following;

    <a name=MySection></a>

    (Make sure you enable html).

    (2) in your formula URL button that has the ...

    function(){" &"location.reload(true);" &"});" & "void(0);"

    You need to swap out the "0" in the void section to be the following.

    window.location.href='#MySection'

    So the entire thing will look like:

    "javascript:" &
    "$.get('" & 
    $URL & 
    "', function(){" &"location.reload(true);" &"});" & "void(window.location.href='#MySection');"

    This isn't perfect, it jumps a little at the initial 'click' if you aren't exactly on the text element already.  And depending on the load time for child records, it could put you on the element, but the form 'grows' as all the child records are loaded.
    But it will get you close.  You can always play around with the positioning of your text element to see if that helps.