?
Solved

How do I occupy a text field using javascript?

Posted on 2011-09-16
3
Medium Priority
?
252 Views
Last Modified: 2013-11-11
I am trying to occupy a text field (t_employment__start_date)on my aspx web page using javascript.  The function is contained in another file that the page calls (I know this is mapped correctly because another function is used and working correctly on the page).  This is the javascript function I created:


function PopulateDate()
{
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
document.getElementById('t_employment__start_date').value =(month + "/" + day + "/" + year);
}


Attached is the source for the web page

Any advice? Thanks.
pagesource.htm
0
Comment
Question by:neilsav
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Author Comment

by:neilsav
ID: 36550610
Sorry I forgot to mention I am trying to display the current date
0
 
LVL 58

Expert Comment

by:HainKurt
ID: 36550831
nothing wrong in this script
<input id='t_employment__start_date'>
<script>
function PopulateDate(){
  var currentTime = new Date();
  var month = currentTime.getMonth() + 1;
  var day = currentTime.getDate();
  var year = currentTime.getFullYear();
  document.getElementById('t_employment__start_date').value =(month + "/" + day + "/" + year);
}
PopulateDate()
</script>

Open in new window

0
 
LVL 58

Accepted Solution

by:
HainKurt earned 2000 total points
ID: 36550839
just make sure you call PopulateDate() after html element, or call this function on body onLoad event

<body onLoad="PopulateDate()">
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question