<?php
$date="2016-01-01";
?>
<script type="javascript">
$(document).ready(function(){
$('#prev').click(function(){
var myVar2=<?php echo json_encode($date);?>;
alert(myVar2);
var myVar=<?php $date2=date('Y-m-d',strtotime('-1 day',strtotime($date))); $date=$date2; echo json_encode($date); ?>;
alert(myVar);
myVar2=<?php echo json_encode($date);?>;
alert(myVar2);
}
})
</script>
<input type="button" value="prev" id="prev" />
I need to decrement the value of the variable date every time the button with id="prev"
is clicked.
The problem here is that the value of the variable date is not getting updated