Hey there! I'm diving into the world of coding and eager to learn. Recently, I successfully passed a query parameter into a JavaScript variable using the following code:
const queryString = window.location.search;
console.log(queryString);
const urlParams = new URLSearchParams(queryString);
var name = urlParams.get('id')
Now, my goal is to transfer this information into JSON within the designated div below:
<div
class="review-form"
data-site-uuid="xxxxxx"
data-form-uuid="xxxxxx"
data-prefill='{"firstName":name}'
></div>
This way, the parameter will seamlessly populate on the review form as intended. Any tips or guidance would be greatly appreciated!
I initially attempted to insert the JavaScript variable directly into the field, only to realize it required JSON formatting.