G
Guest
I have a textbox and an HtmlInputButton control on a Webform for an Intranet
app. When the user clicks the button, it is supposed to add today's date to
the textbox using JavaScript on the client side.
However, it is adding last month's date to the textbox, not today's date. I
checked the regional settings and date/time section of both the client
machine and the web server. Both are set correctly for CA and daylight
savings time, and both show the correct date/time on the Taskbar.
Here is the JavaScript I'm using that I found Googling:
function addDate(){
TheDate = new Date();
var theMonth = TheDate.getMonth();
var theDay = TheDate.getDate();
var theYear = TheDate.getFullYear();
if (document.getElementById('txtFollowUpNeeds').value == ''){
document.getElementById('txtFollowUpNeeds').value = theMonth + '/' + theDay
+ '/' + theYear + ': ';
}
else {
document.getElementById('txtFollowUpNeeds').value += '\r\n' + theMonth + '/'
+ theDay + '/' + theYear + ': ';
}
}
And here is the line in my Page_Load event:
btnAddDate.Attributes.Add("onClick", "addDate();")
Any ideas on how to make this work?
Thanks in advance!
app. When the user clicks the button, it is supposed to add today's date to
the textbox using JavaScript on the client side.
However, it is adding last month's date to the textbox, not today's date. I
checked the regional settings and date/time section of both the client
machine and the web server. Both are set correctly for CA and daylight
savings time, and both show the correct date/time on the Taskbar.
Here is the JavaScript I'm using that I found Googling:
function addDate(){
TheDate = new Date();
var theMonth = TheDate.getMonth();
var theDay = TheDate.getDate();
var theYear = TheDate.getFullYear();
if (document.getElementById('txtFollowUpNeeds').value == ''){
document.getElementById('txtFollowUpNeeds').value = theMonth + '/' + theDay
+ '/' + theYear + ': ';
}
else {
document.getElementById('txtFollowUpNeeds').value += '\r\n' + theMonth + '/'
+ theDay + '/' + theYear + ': ';
}
}
And here is the line in my Page_Load event:
btnAddDate.Attributes.Add("onClick", "addDate();")
Any ideas on how to make this work?
Thanks in advance!