7.0
Table Of Contents
7.2 Populating fields with computed values
The following sample populates a user input field of a PSM document with the current date (New Document
section). First a string is created (toDay) with the current date. The last line in the code retrieves the input
field based on the fields label (Today:) and populates the input field with the computed date string.
<script type="text/javascript">
$(document).ready( function(){
var currentDate = new Date()
var month = currentDate.getMonth() + 1
var day = currentDate.getDate()
var year = currentDate.getFullYear()
var toDay = month + "/" + day + "/" + year
$("span:contains('Today:')").next("input").val(toDay);
});
</script>
Todays date is automatically entered in the input field.
The code sample could be added directly into the template.php file and/or included using an external
Javascript file.
Objectif Lune Inc. © 2010 48