We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39357
    • 13 Posts
    Hi all

    I have a site which displays a gallery of images. The user can vote on the images, and my approach has been to pass variables to a snippet which makes the call to a DB.

    The syntax is something like:
    domainame.com/?Var1=Val1&Var2=Val2 etc etc. 
    


    This works fine. However as the page is pretty long, whenever a user votes on an image at the bottom of the page, the page reloads and starts from the top again.
    I would like the page to return to the same scroll position so the user sees the same image as he/she has just voted on.

    My idea where to apply a name or id value (html) to each image, and include that in the URL.

    fx.
    domainame.com/?Var1=Val1&Var2#ImageName
    or
    domainame.com/?Var1=Val1&Var2#ImageId
    
    I've also tried:
    domainame.com/#ImageName?Var1=Val1&Var2
    


    None of this works. The page returns to the correct image in both examples, but the snippet cease to work properly.
    What is the correct syntax for using both variables and name tags?


    Thanks in advance
      • 3749
      • 24,544 Posts
      IIRC, this should work:

      [[~[[*id]]? &var1=`val1` &var2=`val2`]]#ImageName



      Be sure to use back-ticks around the values.


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting