Date js Calculation problem

cytino

New Member
Hi
I have 2 elements:
Element 1 = Date Element
Element 2 = Text Field

I have a file called 1.js in my js folder whwere 1 is the form ID.

The js is as follows:

function lifetimer()
{
var dateArray = $('warningnotice___debt_due_date').value.split('-');
var today = new Date()
var dyear = parseInt(dateArray[0]);
var dmonth = parseInt(dateArray[1]) - 1;
var dday = parseInt(dateArray[2]);
var debtDate = new Date(dyear, dmonth, dday);
var msPerDay = 24 * 60 * 60 * 1000 ;
var e_daysold = (today.getTime() - debtDate.getTime()) / msPerDay;
$('warningnotice___days_old').value = Math.floor(e_daysold);
}

I have used lifetimer() to call the function in both elements - only one or other element
I have tried the date element to evaled or not

I cannot see what I am doing wrong here?

Any Ideas.
 
Why would you be calling it from the 'days_old' element? You only want to call it from the due_date element, so when that changes, the days_old is calculated.

-- hugh
 
I have tried the calling the function from boith elements andalso just one element.

Have gone over everything again and am calling the function (onchange)from the debt_due_date element only and I still get the following error?

[Exception... "'Permission denied to get property HTMLDivElement.parentNode' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no]

Line 0
 
Can you point me at the page?

Also, can we keep all this stuff in one thread? We seem to have several going about your javascript issues.

-- hugh
 
Don't take offense. I'm just getting confused between your two JS issues. I thought we had two threads about the same bit of JS, but they are indeed different.

-- hugh
 
Please understand that you couldn't offend me if you tried.
I look upon the fabrik team as GODS.
 
If you want to PM me a backend login, I can have a go at fixing some of the more obvious problems on that page.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top