How to fix duplicate web3form contact forms not working on the same page?

xnyjyh
Explorer
212 0 11

Hello.

So im having an issue with 2 of the same web3form contact forms(both different edits for different things) on the same page. They both do not work on the same page. 

Im pretty sure I just cant have the same script names, but I'm no too sure how to change them so they both work on the same page. Do I need a separate access key for each form, perhaps?

 

This is the script - let me know if you see what needs to be done, thanks so much!

 

<div class="contact-container"><form method="POST" id="form"><input type="hidden" name="access_key" value="MY KEY BLOCKED FROM VIEW"> <input type="hidden" name="subject" value="New Interac e-Transfer order"> <input type="hidden" name="from_name" value="JUST TEXT NAME">
  
ALL MY FORM STUFF XXX

<center>
<div id="result" style="font-family: Work Sans; font-size: 12px; font-weight: 400; color: black;"></div>
</center>
</form></div>

<script>
const form = document.getElementById('form');
const result = document.getElementById('result');

form.addEventListener('submit', function(e) {
  e.preventDefault();
  const formData = new FormData(form);
  const object = Object.fromEntries(formData);
  const json = JSON.stringify(object);
  result.innerHTML = "Sending, please wait..."

    fetch('https://api.web3forms.com/submit', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Accept': 'application/json'
            },
            body: json
        })
        .then(async (response) => {
            let json = await response.json();
            if (response.status == 200) {
                result.innerHTML = json.message;
            } else {
                console.log(response);
                result.innerHTML = json.message;
            }
        })
        .catch(error => {
            console.log(error);
            result.innerHTML = "Oops, something's not right...";
        })
        .then(function() {
            form.reset();
            setTimeout(() => {
                result.style.display = "none";
            }, 3000);
        });
});
</script>
<style><!--
body {font-family: Work Sans;
      font-size:14px;
      font-weight:400;
      opacity:100%;
      color:black;
  }
* {box-sizing: border-box;}
@media (max-width: 749px) {
  body {font-family: Work Sans;
        font-size:12px;
        }
  }
@media (min-width: 750px){
  .sm-title {
    font-size: 14px!important;
    font-weight: 600;
  }
}
   @media (max-width: 749px) {
       .sm-title {
    font-size: 12px!important;
    font-weight: 600;
     }
  }
      .sub-news{
      font-size: 14px;
      color: black; 
      font-weight: 400;
      opacity:100%;
    }
  @media (max-width: 749px) {
    .sub-news{
      font-size: 12px;
      color: black; 
      font-weight: 400;
      opacity:100%;
    }
  }
input[type=text], select, textarea {
  font-family: Work Sans;
  font-size: 14px;
  width: 100%;
  padding: 12px;
  padding-left:0px;
  border: 1px solid transparent;
  border-bottom: 1px solid black!important;
  box-sizing: border-box;
  margin-top: 6px;
  margin-bottom: 16px;
  resize: vertical;
}
@media (max-width: 749px) {
  input[type=text], select, textarea {
  font-family: Work Sans;
  font-size: 12px;
  width: 100%;
  padding: 12px;
  padding-left:0px;
  border: 1px solid transparent;
  border-bottom: 1px solid black!important;
  box-sizing: border-box;
  margin-top: 6px;
  margin-bottom: 16px;
  resize: vertical;
}
  }
input[type=text], select, textarea:focus{
    outline: none;
}

.submit {
  width: 100%;
  font-size: 14px;
  font-family: Work Sans;
  background-color: transparent;
   border: 1px solid black;
  color: black;
  padding: 12px 20px;
  cursor: pointer;
  font-weight:500!important;
}
@media (max-width: 749px) {
  .submit {
  width: 100%;
  font-size: 12px;
  font-family: Work Sans;
  background-color: transparent;
   border: 1px solid black;
  color: black;
  padding: 12px 20px;
  cursor: pointer;
  font-weight:500!important;
}
  }
.contact-container {
  background-color: none;
  padding: 0px;
padding-top:0px;
padding-bottom:200px;
}
@media only screen and (max-width: 749px) {
.contact-container {
  background-color: none;
  padding: 0px;
}

::placeholder {
  color: black;
  opacity: 1; /* Firefox */
}
input[type=checkbox] {
  margin-top: 26px;
  accent-color:black;
  margin-left:0px;
}
--></style>

 

Replies 0 (0)