Jump to content

Form not passing hidden values

Recommended Posts

Posted

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
  $.getJSON('https://api.ipify.org?format=json')
    .done(function(data) {
      var ipAddress = data.ip;
      $.getJSON('https://ipapi.co/' + ipAddress + '/json')
        .done(function(data) {
          $('input[name="SQF_IP_ADDRESS"]').val(ipAddress);
          $('input[name="SQF_CITY"]').val(data.city);
          $('input[name="SQF_COUNTRY"]').val(data.country);
        })
        .fail(function() {
          console.error('Failed to retrieve city and country information.');
        });
    })
    .fail(function() {
      console.error('Failed to retrieve IP address.');
    });
});
</script>
 

 

This code does not pass the hidden values to email. I've already created a hidden field with the exact name. let me know 

  • Replies 3
  • Views 515
  • Created
  • Last Reply

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.