View Single Post
  #4 (permalink)  
Old 10-20-07, 10:43 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
If you want to use the js in a function then you could do it like this:

date.js
Javascript Code:
  1. function get_year(id)
  2. {
  3.  var d = new Date();
  4.  var y = d.getYear();
  5.  document.getElementById(id).value = y;
  6.  }

Your page:
HTML Code:
<html>
<head>
<script src='date.js'></script>
</head>
<body>
<input name="pub_year_id" id="pub_year_id">
<input name="current_year" id="current_year">
<script>
get_year("pub_year_id");
get_year("current_year");
</script>
</body>
</html>
__________________
Jerry Broughton

Last edited by job0107; 10-20-07 at 10:46 PM.
Reply With Quote