[Answer]-Refresh the value of variable javascript

0👍

Try this :

$(document).ready(function(){
    $('#datetimepicker').datetimepicker("setDate", aaa);
}

Try this, if this works then try adding other stuffs.

1👍

Since you din’t link a reference for jquery datetimepicker(),
I assume you’re talking about this:
http://xdsoft.net/jqplugins/datetimepicker/

In order to accomplish your task, you have to:

  1. be sure that your timepicker starts after document loading using document.ready
  2. you’re calling datetimepicker() on $('#datetimepicker'), then you’re calling it again on an already jquery/datepicker object, with new parameters. I don’t know if it may cause initialization problems, but i can assure you that it’s useless.
  3. if you want to change datepicker value on the fly, you have to use it’s own method like in this example: http://xdsoft.net/jqplugins/datetimepicker/#runtime_options

here’s the code:

<script type="text/javascript">       
    $(document).ready(function(){
        $('#datetimepicker').datetimepicker({
            value : {{ now_date|date:'Y-m-d H:i' }},
            step : 10
        });
    });
    //below, an example of data variable refresh
    $('#datetimepicker').setOptions({value : {{ now_date|date:'Y-m-d H:i' }} });
</script>

Leave a comment