Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nicholas Westby 2054 posts 7104 karma points c-trib
    Nov 30, 2021 @ 20:38
    Nicholas Westby
    0

    Set Hidden Field Value to Cookie value in Plain JavaScript Template

    Somebody asked me how to set a hidden field value to a cookie value in Formulate using the plain JavaScript template. There are two straightforward ways of doing this. For both, I recommend creating a new field category and setting the field to have that category.

    For the first approach, you can set the field value to the cookie value using JavaScript. This page has a function to get a cookie value: https://www.w3schools.com/js/js_cookies.asp

    You can then set the value of your field to that cookie value:

    document.querySelector("[data-category='Something']").value = getCookie("Something");
    

    Change out the name of your field category and cookie.

    This talks a bit about how it can be done server side: https://our.umbraco.com/packages/backoffice-extensions/formulate/formulate-questions/87639-no-code-generate-by-hidden-field

    And if you are still using the AngularJS template: https://our.umbraco.com/packages/backoffice-extensions/formulate/formulate-questions/93777-formulate-set-hidden-field

  • Nicholas Westby 2054 posts 7104 karma points c-trib
    Nov 30, 2021 @ 20:39
    Nicholas Westby
    100

    The answer is in the question. Just posting this as the answer so I can mark it as solved.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies