I'm pretty new to jQuery so I'm a little confused on how to make this work. Basically I have a form that has input fields such as Student ID, Student Name, Student DOB, and Student Age. Once the user has input their information into the fields, I want the input to show below the form in the format:
Student ID: (input value)
Student Name: (input value), etc.
This is my code so far:
$(document).ready(function() {
$("#submitButton").on("click", function(e) {
e.preventDefault();
var input = $("#q1").val()
$("#show").html(input)
})
$("#submitButton").on("click", function(e) {
e.preventDefault();
var input = $("#q2").val()
$("#show").html(input)
}) });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="form">
<table>
<tr>
<label>Student Id <input id="q1" type="text" placeholder="required"/>*</label><br>
<label>Student Name <input id="q2" type="text" placeholder="required"/>*</label><br>
<label>Student DOB <input id="q3" type="datetime" placeholder="required"/>*</label><br>
<label>Student Age <input id="q4" type="number" placeholder="required"/>*</label><br>
</tr>
</table>
<button type="button" id="submitButton" class="button">Login</button>
<span id="show"></span>
As of right now, when you press "submit" only the second value entered is shown, not the first. I eventually need to have all fields showing on the bottom, but the second value is currently on the left side of the form. Any help/guidance is appreciated!