I'm not a Javascript guru and would appreciate some help. Basically, I'm taking the difference between two dates and then displaying the numbers of weeks with a remainder. If the first remainder decimal is 7 or greater, they want the number rounded up to the next whole number. If it's a whole number, just tack on a ".0" for consistency. I've tried the following, but it doesn't seem to work. Can anybody help or is there a cleaner way to do it?
Code:var x = document.getElementById('txtDueDate').value; var y = document.getElementById('txtAdmit').value; var dt1 = Date.parse(x) var dt2 = Date.parse(y) var ga = Math.round(((280 - (dt1.valueOf() - dt2.valueOf()) / (60 * 60 * 24 * 1000)) / 7) * Math.pow(10, 1)) / Math.pow(10, 1); if (inStr(ga,".") = -1) { document.getElementById('txtGaAdmit').value=ga + ".0" } else { if (ga.subStr(inStr(ga,".")+1,1) >= 7) { document.getElementById('txtGaAdmit').value = (ga.subStr(0, inStr(ga, ".") - 1) + 1) + ".0" } else { document.getElementById('txtGaAdmit').value=ga } }


Reply With Quote

Bookmarks