Valid JavaScript not working
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?
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?
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)
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)
-
- Information
-
Who is online
Users browsing this forum: No registered users and 5 guests