I've got a page which submits two dates so that a chart is made for the corresponding period. The key form attributes, startdate and enddate, are hidden and calculated based on what is filled into different form fields. In stead of updating startdate and enddate every time one of the visible fields is changed, I wanted to only do it once, on submit (by a JavaScript function called when the onsubmit event of the form occurs). Can it be done, or is it too late then? Because it does not appear to be working.
EDIT: I found a workaround, I call the function when onclick event for the submit button occurs (works when I activate it by keyboard too

). I'd still like to know if what I previously tried should or should not work?