There were similar questions, but not exactly what I'm looking for. I have a filter for my table with 1 button that changes the value of a textbox to the currant date. That works fine, but right next to it, theres a button to clear the content in the textbox. This second button doesnt seem to work.
My code :
function today() {
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0');
var yyyy = today.getFullYear();
today = yyyy + '.' + mm + '.' + dd;
document.getElementById("myInput").value = today;
}
function clear() {
document.getElementById("myInput").value = "";
}
<div class="form-inline">
<label for="myInput">Filter By:</label>
<input class="input-xsmall" type="text" maxlength="10" placeholder="yyyy.mm.dd" id="myInput" style="width: 100px; margin-bottom: 10px; display: inline-block">
<input type="button" value="Today" onclick="today()">
<input type="button" value="Clear" onclick="clear()">
</div>
Not sure how to get it to work. When I switched the onclick function in the first input as clear()
it worked so for some reason the second input button doesnt work. How can I fix that?