I have a list of checkboxes that I want to display based on current time when user clicks a button.
JS:
var hour = (new Date()).getHours();
showMed('A', hour == 19);
showMed('B', hour == 19);
showMed('C', hour == 13);
function showMed(med, show) {
document.getElementById('med' + med).style.display = show ? '' : 'none';
}
HTML
<div class="inner" id=text><button onClick="showMed()">Check</button></div>
<form>
<div id='medA'>
<input type="checkbox" name="Med A" value="A">Medication A
</div>
<div id='medB'>
<input type="checkbox" name="Med B" value="B">Medication B
</div>
<div id='medC'>
<input type="checkbox" name="Med C" value="C">Medication C
</div>
</form>
I want the user to click the button and it will display the checkboxes based on the current time. But at the moment I can't seem to call the function
Aucun commentaire:
Enregistrer un commentaire