Form Field ID for Custom Script


#1

I’d like to ask if anybody knows the script on how to get hidden field ID e.g. Hidden field ID is “hiddenField” then we’d like to assign a dynamic value to Hidden Field.

Our Sample code:

document.getElementById(‘hiddenField’).value = window.location.href.split(’?’)[1];

A response is really appreciated.


Passing a querystring variable to a hidden field
#2

Hey! This seems related :wink: Passing a querystring variable to a hidden field

Here’s a limited solution where “something” is your query param and “randomField” is the thing you want to pass along when the form is submitted.

<script>
  $(document).ready(function () {
    var urlParams = new URLSearchParams(window.location.search);
    document.getElementById('randomField').value = urlParams.get('something');
  });
</script>