oninput JavaScript Date Function Calculator -
oninput JavaScript Date Function Calculator -
i found code online , unable work correctly can please tell me going wrong? description made sound work how need reason cannot work correctly on end. have been putting bunch of alerts , cannot them display. sorry new trying teach myself javascript.
input button:
<cfinput type="datefield" name="purchasedate" width="130" required="yes" message="please come in purchase date." value="#dateformat(now(),"mm/dd/yyyy")#" oninput="calculatetotal();" > javascript function:
function getdateprice(date) { var dateprice = 0 var theform = document.forms["form"]; var purchasedate = theform.elements["purchasedate"]; var date = new date(purchasedate.value); if (object.prototype.tostring.call(date) !== '[object date]') { date = new date(); } var today = new date(); var diffmilli = today - date; var diffdays = diffmilli * 1000 * 60 * 60 * 24; if (diffdays > 30) { dateprice= 20; } homecoming dateprice; } function calculatetotal() { var titlefees = getdateprice(date); var divobj = document.getelementbyid('totalprice'); divobj.style.display='block'; divobj.innerhtml = "estimated transfer fees $"+titlefees; } function getdateprice() { // don't pass arguments ..* var theform = document.forms.form; // utilize rather dot notation var purchasedate = theform.elements.purchasedate; // utilize rather dot notation var date = new date(purchasedate.value); // *.. cause you'll here value if (object.prototype.tostring.call(date) !== '[object date]') { date = new date(); } var today = new date(); var diffmilli = today - date; // today - date = time in milliseconds... // if multiply value you'll astronomic number so, days.. var diffdays = math.floor(diffmilli / 1000 / 60 / 60 / 24); // ..divide! var dateprice = 0; if (diffdays > 30) { dateprice = 20; } homecoming dateprice; } function calculatetotal(){ var divobj = document.getelementbyid('totalprice'); divobj.style.display = 'block'; divobj.innerhtml = "estimated transfer fees $"+ getdateprice(); }
live demo
and input event utilize oninput="calculatetotal();"
javascript
Comments
Post a Comment