PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Copying data from one field to another

  1. DigitalC
    Member

    I'm building a form that's a bit like a time sheet where someone enters their job info for Monday, then job info for Tuesday, job info for Wednesday and so forth. On most days, this job info is identical from day to day. Is it possible to add a checkbox that allows someone to "copy" data from previous fields into subsequent fields?

    So for example, if someone did the same job on Monday and Tuesday, they could enter in the info into Monday, then click "copy to next day" and automatically populate Tuesday without having to manually re-type all the info.

    Posted 11 years ago on Tuesday September 4, 2012 | Permalink
  2. You can do this, with JavaScript or jQuery. Here are a couple explanations online:
    http://www.encaffeinated.com/articles/view/copying_billing_and_shipping_address_information_with_jquery/
    http://stackoverflow.com/q/2706756

    I searched for "shipping same as billing JavaScript" which is where you see this functionality usually. The procedure would be the same: add some JavaScript functionality to copy data from one field to another one the same page, with limited user interaction.

    Posted 11 years ago on Tuesday September 4, 2012 | Permalink
  3. DigitalC
    Member

    Does this integrate with the Gravity forms? I'm not sure how that works. I actually have a Gravity Form that I built, the question remains to whether I can add the "copy" functionality. I see the custom JavaScript info you sent but again, not sure how this would integrate with Gravity Forms. Is there someplace I could start or a document about using custom JS with Gravity Forms?

    Posted 11 years ago on Tuesday September 4, 2012 | Permalink
  4. Any JavaScript can be used with Gravity Forms, or any page on your website. It's not built in to Gravity Forms, but is external functionality which you can add.

    You can use the gform_enqueue_scripts filter to add any required scripts to the page which holds the Gravity Form: http://www.gravityhelp.com/documentation/page/Gform_enqueue_scripts

    The basic procedure will be to create your form, then based on your form and the fields you want to duplicate, write the JavaScript to copy the data from field to field. Save that JavaScript to your server, then add that JavaScript to the page where the Gravity Form is shown. There are a few pieces to it, but it's not a complicated customization. It requires JavaScript and WordPress skills.

    Posted 11 years ago on Tuesday September 4, 2012 | Permalink