7.1

Table Of Contents
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.
Removing elements from the DOM
The following snippet is a simple sample on how to remove an HTML element based on its ID. The element is removed once
the page is rendered by the browser.
<script type="text/javascript">
$(document).ready( function(){
$("#legend_joboverviewList").remove();
});
</script>
Removing elements is not without risk and should be tested carefully (especially save actions).
©2010 Objectif Lune Inc - 252 -