So I have a button that submits a form. There’s also a JS function that formats and saves the user input in localStorage so as to display on the confirmation landing page.
The function works perfectly if I submit the form and then go to the confirmation page manually. However, I can’t make the button both execute the function and go to the confirmation page at the same time.
<button id="submitForm" onclick="getFormInputValues(); window.location.href='/common/confirmation.html'">Make Reservation</button>
For some reason I’m notunderstanding. When I click on the Make Reservation button, it does execute the function, but it doesn’t change the page. If I click a second time on the button, it does go to the confirmation page, but it doesn’t execute the function. If I type text in the fields before clicking the button, it just never works. It will only ever change pages if the function is unable to execute.
Thanks in advance for your help.
/* Booking Page */
var nameField = document.getElementById("nameInput");
var emailField = document.getElementById("emailInput");
var dateDayField = document.getElementById("day");
var dateMonthField = document.getElementById("month");
var dateYearField = document.getElementById("year");;
var timeHourField = document.getElementById("hour");
var timeMinuteField = document.getElementById("minute");
var timeAmPmField = document.getElementById("am-pm");
var numberOfPeopleField = document.getElementById("numberOfPeople");
/* Variables for local storage */
var storedName = localStorage.getItem("storedName");
var storedEmail = localStorage.getItem("storedEmail");
var storedDate = localStorage.getItem("storedDate");
var storedTime = localStorage.getItem("storedTime");
var storedNumberOfPeople = localStorage.getItem("storedNumberOfPeople");
/* Functions */
function getFormInputValues() {
/* Name */
nameFieldUserInput = nameField.value;
localStorage.setItem("storedName", nameFieldUserInput);
/* Email */
emailFieldUserInput = emailField.value;
localStorage.setItem("storedEmail", emailFieldUserInput);
/* Date */
dateUserInput = dateMonthField.value + "/" + dateDayField.value + "/" + dateYearField.value;
localStorage.setItem("storedDate", dateUserInput)
/* Time */
timeUserInput = timeHourField.value + ":" + timeMinuteField.value + " " + timeAmPmField.value;
localStorage.setItem("storedTime", timeUserInput);
/* Guests Number */
numberOfPeopleUserInput = numberOfPeopleField.value;
localStorage.setItem("storedNumberOfPeople", numberOfPeopleUserInput);
};
function displayFormValues() {
document.getElementById("nameDisplay").innerHTML = storedName;
document.getElementById("emailDisplay").innerHTML = storedEmail;
document.getElementById("dateDisplay").innerHTML = storedDate;
document.getElementById("timeDisplay").innerHTML = storedTime;
document.getElementById("numberOfPeopleDisplay").innerHTML = storedNumberOfPeople;
};
buy prednisone – prednisone 50 mg price price of prednisone tablets
modafinil online – order modafinil provigil vs nuvigil
buy accutane cream – accutane where to purchase cheapest accutane prices
over the counter amoxicillin kroger – buy amoxicilina 500 mg amoxicillin without a doctorвЂs prescription
buy vardenafil line – buy vardenafil with no prescription generic vardenafil vs
ivermectin for humans for sale – generic ivermectin cream purchase stromectol
onlinepharmacytabs24 com – online pharmacy indonesia med pharmacy
ivermectin lotion for scabies – fda ivermectin ivermectin price uk
best price generic accutane – cheapest generic accutane accutane discount
lyrica 15 mg – 800 mg lyrica canada pharmacy
buy amoxicilin noscript – amoxicillin without a doctorвЂs prescription buy amoxicilina 500 mg online
sildenafil india buy – viagra australia buy viagra brand
cialis price in south africa – cialis for sale in mexico buy genuine cialis
ivermectin price canada – ivercitin cost for ivermectin 3mg
buy prednisone india – prednisolone vs prednisone prednisone uk online
provigil 200mg – buy provigil online provigil 100 mg
zithromax 250mg online – z pak zitromax
can you order furosemide without a prescription online – buy furosemide 100 mg order lasix without a prescription
cost of clomid – order clomid 50mg buy clomiphene
sildenafil 100 capsule – sildenafil paypal cheap viagra online india
ivermectin cream – stromectol price uk stromectol generico
buy ivermectin cream – stromectol for humans for sale generic stromectol online
erectile dysfunction medications – soma therapy ed best non prescription ed pills
neurontin india – neurontin 50mg cost generic cost of levothyroxine
purchasing amoxicillin online – buy amoxicillin 500 mg india walmart price for amoxicillin
get viagra prescription online – Viagra next day delivery femail viagra
ventolin cost uk – ventolin price in india cheap albuterol
ivermectin 5 mg – stromectol ireland ivermectin 9mg
online tadalafil – buy tadalafil generic online buy tadalafil online cheap
how to get viagra us – Brand cialis for sale tadalafil 5mg buy
levitra pills – vardenafil 20mg over the counter erectile dysfunction pills
orlistat mice – xenical nih orlistat million
viagra pills generic brand – viagra 50mg for sale online viagra usa
cialis soft tabs 10mg – 20 cialis mg tadalafil cialis com
50 mg prednisone from canada – medication prednisone can i buy prednisone online in uk
stromectol 3 mg tablet price – stromectol order ivermectin over the counter
medication prednisone 20 mg – prednisone drugs prednisone drug
viagra generique pas cher – sildenafil kaufen fГјr mГ¤nner acheter 20mg cialis en ligne
https://cialisicp.com/ cialis cost
order accutane sale – buy accutane pills amoxicillin us
tadalafil blood pressure buy generic cialis online with mastercard
https://cialismat.com/ lowest price cialis
https://cialisedot.com/ where to buy cialis without prescription
tadalafil liquid buy generic cialis online with mastercard
generic cialis online fast shipping side effects for tadalafil
tadalafil blood pressure generic tadalafil from uk
cheap generic cialis for sale tadalafil
buy stromectol online generic ivermectin 6 mg
how to get ivermectin from india buy 6mg ivermectin
order stromectol online buy ivermectin in canada