Hi, I am trying to reset all the form fields with JavaScript's reset() method by calling a function on button click but one filed i.e. paragraph field doesn't reset, what should I do ?
HTML:
<form action="#" id="myForm">
<input type="text" id="text">
<select id="select">
<option value="Select" selected>Select</option>
<option value="Lahore">Lahore</option>
<option value="Karachi">Karachi</option>
</select>
<input type="checkbox" name="" id="chkbox">
<button onclick="Check()">Submit</button>
<button onclick="resetForm()">Reset</button>
<p id="paragraph"></p>
</form>
JavaScript:
function resetForm() {
document.getElementById("myForm").reset();
document.getElementById("paragraph").reset();
}
function Check(){
var text=document.getElementById("text").value;
console.log(text);
var select=document.getElementById("select").value;
console.log(select);
var checkbox=document.getElementById("chkbox").value;
console.log(checkbox);
document.getElementById("paragraph").innerHTML=text+" "+select+" "+checkbox;