Hi,
I am designing a form to submit to a hospital as a request for an obstetric US scan. Two of the fields directly relate on the form, LNMP (the first day of the last menstrual period) and EDD (the estimated due date) these fields are exactly 40 weeks apart.
In the calculation fields of either box I placed this script;
var strStart = this.getField("LMNP/EDD").value;
if(strStart.length)
{
var dateStart = util.scand("dd/mm/yy",strStart);
var fW = 24 * 60 * 60 * 1000 * 7 * 40;
var dueMillis = dateStart.getTime() + fW;
var dueDate = new Date(dueMillis);
event.value = util.printd("dd/mm/yy",dueDate);
}
else
event.value = "NA";
This accurately calculates the other box when data is entered into one although upon re-entry (if someone has made a mistake and needs to change it) one box predominates and only that one can change the data.
(i.e. If data is entered into the LMNP it reverts to the date already there based upon the EDD.)
I have attempted to make a reset button but these form fields can't be left blank as a warning appears after every action if the fields have nothing in them.
I'm stuck now.... help!
George