If I understood correctly, the user enters the arrival date and departure date while on the page and as soon as he entered both dates, it is necessary for him to output the total amount.
If this is not true, then clarify the question and I will rewrite the answer, and if this is correct, then there is a work with dates
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <label for="dtarrive">Дата заезда</label> <input type="date" class="form-control" id="dtarrive" name="dtarrive"/> <label for="dtdepart">Дата выезда</label> <input type="date" class="form-control" id="dtdepart" name="dtdepart"/> <label for="price">Цена за 1 день</label> <input type="hidden" class="form-control" id="price" name="price" value="10000" /> <input type="text" class="form-control" value="10000" disabled /> <label for="price">Итоговая цена</label><span id="cost"></span> <script> var dtarrive=0, dtdepart=0, price=$('#price').val(); $('#dtarrive,#dtdepart').change(function(){ dtarrive=$('#dtarrive').val(); dtdepart=$('#dtdepart').val(); if(dtarrive && dtdepart ) { //для I-7 //dtarrive=new Date(dtarrive.replace(/(\d+)-(\d+)-(\d+)/, '$2/$3/$1')); dtarrive=new Date(dtarrive); dtdepart=new Date(dtdepart); var cost=Math.round((dtdepart-dtarrive)/1000/3600/24)*price; $('#cost').text(cost); } }); </script>
as you can see for clarity, I substituted the cost of the day 10,000 and connected the jquery library to quickly access the elements, also added the output to the span