Fill a field with the current Page/post Title
-
I want to dynamically pre populate a form input field with the page/post title using a hidden field. I found an old post in this forum with a function to put a hidden field value in the text field. The hidden field holds the page title. But I am lost on how to make it work.
The code is
(function() {
const hidden = document.querySelector(‘#forminator-module-4000 #hidden-1’);
document.querySelector(“#forminator-module-4000 #textarea-2”).value = hidden.value;
})();I am using the WPCode plugin to put the code in the page. I can see it in Page Source. The form and field IDs are what I am using.
Normally only people who login to the site can see the form (to make an enquiry). I have removed that restriction which means the Name and Email fields on the form are not prefilled. The Page is
https://www.aaq.org.au/13-truss-tube-dobsonian/
I have exported the Form and placed at https://pastebin.com/n7d9xBCV
Can someone help?
- The topic ‘Fill a field with the current Page/post Title’ is closed to new replies.