Skip to main content

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(’?’)f1];


A response is really appreciated.

Hey! This seems related 😉 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>

Reply