0

Basically i have this sum in excel

=SUM((B3/365)*(B4-B5)+B6)

i want to recreate this sum in a form in javascript the B4 and B5 are dates so this has confused my already limited knowledge of building something.

Heres what i have already.

     <script>
if (datefield.type!="date"){ //if browser doesn't support input type="date", initialize date picker widget:
   jQuery(function($){ //on document.ready
       $('#B4').datepicker();
       $('#B5').datepicker();
   })
}
</script>
<script>
 function calc(){
var B3=document.getElementById('B3').value;
var B4=document.getElementById('B4').value;
var B5=document.getElementById('B5').value;
var B6=document.getElementById('B6').value;
var days=B3/365;
var dates=B4-B5
var total=(days*dates)+B6;
document.getElementById('result').innerHTML=total;
 return false
}
</script>
</head>
<body>
<form>
<p>Annual Premium<input type="text" id="B3"/></p>
<p>Date policy should be canx<input type="date" id="B4" /></p>
 <p>Equity Date<input type="date" id="B5" /></p>
<p>Canx fee<input type="text" id="B6" /></p>
<input type="button" onClick="calc()" value="Calcular" />
</form>
<div id="result"></div>
</body>
</html>

0 Answers0