geethareddy commited on
Commit
1bfdeb9
·
verified ·
1 Parent(s): fddd003

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +16 -3
templates/index.html CHANGED
@@ -246,7 +246,7 @@
246
  const name = document.getElementById('name').value;
247
  const email = document.getElementById('email').value;
248
  const phone = document.getElementById('mobile').value;
249
-
250
  fetch('/submit', {
251
  method: 'POST',
252
  headers: { 'Content-Type': 'application/json' },
@@ -255,10 +255,23 @@
255
  .then(response => response.json())
256
  .then(data => {
257
  if (data.success) {
258
- window.location.href = '/menu'; // Redirect to menu after successful registration
 
 
 
 
 
 
 
 
259
  } else {
260
- alert('There was an error. Please try again.');
 
261
  }
 
 
 
 
262
  });
263
  }
264
 
 
246
  const name = document.getElementById('name').value;
247
  const email = document.getElementById('email').value;
248
  const phone = document.getElementById('mobile').value;
249
+ // Simulate submission to Salesforce
250
  fetch('/submit', {
251
  method: 'POST',
252
  headers: { 'Content-Type': 'application/json' },
 
255
  .then(response => response.json())
256
  .then(data => {
257
  if (data.success) {
258
+ document.getElementById('statusText').textContent = `Thank you for registering, ${name}!`;
259
+ document.getElementById('statusMessage').style.display = 'block';
260
+ // Show 'Submitted Successfully' after 6 seconds, then refresh the page after 5 seconds
261
+ setTimeout(() => {
262
+ document.getElementById('statusText').textContent = 'Submitted Successfully!';
263
+ setTimeout(() => {
264
+ window.location.reload(); // Refresh after 5 seconds
265
+ }, 5000);
266
+ }, 6000);
267
  } else {
268
+ document.getElementById('statusText').textContent = 'There was an error submitting your details. Please try again.';
269
+ document.getElementById('statusMessage').style.display = 'block';
270
  }
271
+ })
272
+ .catch(error => {
273
+ document.getElementById('statusText').textContent = 'An error occurred. Please try again.';
274
+ document.getElementById('statusMessage').style.display = 'block';
275
  });
276
  }
277