For the site I am developing, I use a form to update the different fields of a model.
Some of those fields need to be updated according to the values of others.
For example, each instance of a Task, has a start date, an end date, and a length which have to verify the following : End = Start + Length (where weekends are not counted, but that is a secondary issue).
So one of the functions I am trying to write would do :
When the user changes the value of the input
Start_date
Get that date from the input field
Get the value of the field Length
Update the value of the input "End date" with (Start_date+Length)
The three inputs concerned by my example have the following IDs : id_start, id_length, id_finish.
Here is what I have written, but which doesn't work at all (nothing visible happens...) :
<script>
    $( "#id_start" ).change(function() {
        var start = new Date();
        var finish = new Date();
        var numberOfDays = document.getElementById('id_length').value;
        start = document.getElementById('id_start').value;
        finish.setdate(start.getDate()+document.getElementById('id_length'))
        $('#id_finish').val(finish);
    });
</script>
Any hint at a solution to make it work would be hugely appreciated.
 
     
    