I know this is a commonly posted question so I apologize, but I've tried javascript, jQUERY, parts of this,several versions from previous work that DO work, .value, .textContent, .innerHTML, getAttribute('value'), document.getElementById and just everything else I could think of.
I console.log(user_name.value) and get the value I want, but when I console.log(name) or try to use user_name.value it's just an empty string. I'm new to development and got all the rest of the code working, everything else is hanging on this simple part and I can't solve it yet. Any help would be so appreciated.
HTML:
<form>
<input id="user_name" type="text" placeholder="Your Name" />
<input id="user_email" type="text" placeholder="Your E-mail" />
</form>
JavaScript:
var name;
var email;
function reserveSeat(name, seatNumber, email) {
var name = $('#user_name').getAttribute('value');
var email = $('#user_email').getAttribute('value');
var seatNumber = seatNumbers;
reservedSeats.push (new CustomerReservation (name, seatNumber, email));
console.log(name)
console.log(email)
};
$('.submitBtn').on('click', reserveSeat(name, seatNumber, email));