Page 1 of 1
Valid JavaScript not working
Posted: 22 Dec 2014
by Jdubs
Scenario:
I input JavaScript code, press "save," test client-side form, and form works.
I input additional JavaScript code, "press save," test client-side form, and form no longer works.
I remove additional JavaScript code, "press save," test client-side form, and form still does not work.
To be clear, the code from Line 1 and Line 3 are exactly the same.
Why does the code no longer work?
Re: Valid JavaScript not working
Posted: 22 Dec 2014
by Jdubs
Here's the EXACT scenario:
Line 1 Code (Works!)
//Calculate Date
var calcDate = new Date();
var Month = calcDate.getMonth() + 1;
var Day = calcDate.getDate();
var Year = calcDate.getFullYear();
var vStartDate = Month + "/" + Day + "/" + Year;
var Hour = Math.round(calcDate.getHours());
var Minute = calcDate.getMinutes();
var ampm = Hour >= 12 ? 'PM' : 'AM';
//Pre-populate Date & Time
if(fd.field('StartTime').value() === "")
{
fd.field('StartTime').value(vStartDate);
fd.field('sTime').value(Hour + ":" + Minute + " " + ampm);
};
Line 2 (Does not work!)
//Calculate Date
var calcDate = new Date();
var Month = calcDate.getMonth() + 1;
var Day = calcDate.getDate();
var Year = calcDate.getFullYear();
var vStartDate = Month + "/" + Day + "/" + Year;
var Hour = Math.round(calcDate.getHours());
var Minute = calcDate.getMinutes();
var ampm = Hour >= 12 ? 'PM' : 'AM';
var 12Hour = Hour > 12 ? Hour - 12 : Hour; //New Line of Code
//Pre-populate Date & Time
if(fd.field('StartTime').value() === "")
{
fd.field('StartTime').value(vStartDate);
fd.field('sTime').value(Hour + ":" + Minute + " " + ampm); //New Variable
};
Line 3 (DOES NOT WORK!)
I simply un-do the two lines that I modified in Line 2, save it ... and then it doesn't work. (even though it is EXACTLY the same as line 1)
Re: Valid JavaScript not working
Posted: 22 Dec 2014
by Jdubs
*sigh* Sorry.
I input variable 12Hour on Line 2 on the pre-population line. (the one that I flag //New Variable)
Re: Valid JavaScript not working
Posted: 22 Dec 2014
by Jdubs
One additional note, I just verified this:
When I CLEAR all the JavaScript code, SAVE it, THEN re-paste the original code, then save it again ... the JavaScript code works again.