Hidden form field for IP address capture?
Hey, I'm looking to add a hidden field in my contact form to capture IP addresses. But I can't figure out how to link a hidden field to this capture. I've used the code <input type="hidden" name="hidden1" value="ipFormInput" /> and made the ID of this code ipFormInput.
Then I used the following code to collect the IP address:
<script type="application/javascript "> const ipFormInput = document.getElementById('ipFormInput'); fetch('https://api.ipify.org?format=json') .then((response) => { return response.json() }) .then((json) => { const ip = json.ip; ipFormInput.value = ip; }) .catch((err) => { console.error(`Error getting IP Address: ${err}`) }) </script>
When I test it, the hidden field shows up but it inputs as "ipFormInput".
Here is my read-only link. https://preview.webflow.com/preview/solarcycle?utm_medium=preview_link&utm_source=designer&utm_content=solarcycle&preview=884452980b1b18a08570ae93eb866ed8&workflow=preview
Thanks for any help!