I wrote a script that, in theory, should clean the input when the checkbox:checked . And when checkbox:not(:checked) , then the input should display the value that was before the input was cleared. But my code is not working.
$(function() { var input = $('#back_date'); var value = input.val(); $('#way-indent').change(function() { var clearence = this.checked ? '' : value; $(input).val(clearence); }); });