We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39599
    • 5 Posts
    I have a site with lots of different products. Each product page has a link to request more information. What I want to happen is to pass the title of the product page to the contact form, so that the Formit form will already be filled in with the appropriate Subject field.

    I've been doing this by linking to the contact form using a string afterwards designating which product it is. For example, on the Product 1 page, if you click Request Info you'll be sent to www.site.com/contact?subject=Product 1. And then I use some hacky javascript on the Contact page to plop 'Product 1' into the Subject field so that it's already populated when the page loads.

    But there has to be a better way, right? How can I do this?

    This question has been answered by treigh. See the first response.

    • discuss.answer
      • 30585
      • 833 Posts
      You can achieve this with getUrlParam. Assuming your referring resource id is 10, you'd first need to send the parameter like this:
      [[~10? &product=`Product1`]]

      You can then retrieve it on the contact page with getUrlParam:
      <input type="text" name="subject" value="[[getUrlParam? &name=`product`]]"> 


      Another method involves FormItRetriever, which will require the parameter to be sent (stored) via form submission on the referring page, then you can retrieve the value on the contact page like this:
      [[!FormItRetriever]]
      <input type="text" name="subject" value="[[!+fi.product]]"> 
      // where product is the name of the form field of which you stored the value on the referring page.
      
        A MODx Fanatic
        • 39599
        • 5 Posts
        Perfect answer. Thanks a lot.
          • 30585
          • 833 Posts
          Glad I could help.
            A MODx Fanatic