I am trying to run a javascript function once a user click on a button. I am echoing the script, but nothing is happening.
button code in .php file:
case 'create':
echo '<script type="text/javascript">clearform();</script>';
break;
Javascript file:
function clearform()
{
document.getElementById("serviceMileage").value="";
}
It only displays this in the console:
<script type="text/javascript">clearform();</script>
I want to clear an input field once a user clicks on the button