Click here to Skip to main content
15,902,299 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a code that clears the input text label, but i also need the same button to clear the output message it gives = "helloNameOutput". How would I add the 2 in the same function? I have both my codes listed below, that work perfectly separated, but I cant figure out how to put them together.

What I have tried:

//for removing the Input text label:
onclick = document.getElementById("helloNameInput").value="";


//for removing the Output message recieved:
inputField = document.getElementById("helloNameOP")
   document.getElementById('helloNameOP').textContent = " "
Posted
Updated 28-Jan-22 20:04pm

 function () {
  document.getElementById("helloNameInput").value = "";
  document.getElementById("helloNameOP").textContent = "";
}


got it
 
Share this answer
 
You can write a function in which clear the fields. I have write HTML with Javascript function to demonstrate. Check below code:
<h2>Hello! Clear Me</h2>
<Label id="myLabel">My Label</Label>
<input type="text" value="Blabla" id="myInput">

<button onclick="clickMe()">Clear input field</button>

<script>
function clickMe()
{
	document.getElementById('myInput').value = ''
	document.getElementById("myLabel").innerHTML = "";
}
</script> 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900