Link to home
Start Free TrialLog in
Avatar of neilsav
neilsav

asked on

How do I occupy a text field using javascript?

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
Avatar of neilsav
neilsav

ASKER

Sorry I forgot to mention I am trying to display the current date
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

ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial