I’m creating a form
. How can I make the value of an input
display on the form page without clicking the submit button using php and maybe JavaScript
CodePudding user response:
Add an input event listener to the field and output it where needed.
const input = document.querySelector("#in");
const output = document.querySelector("#out");
input.addEventListener("input", (e) => {
output.textContent = e.target.value;
});
<p>Type text here: <input id="in" /></p>
<p>See result here: <span id="out"></span></p>