Re: Custom Javascript onchange

Originally Posted by
chrislynch8
In my editviewdefs.php i have the following in the templateMeta array after the widths array
PHP Code:
'includes' =>
array(
0 =>
array(
'file' => 'modules/FDC_Aspire/FDC_Aspire.js',
),
),
Then in the field I want it to trigger on I added the following
PHP Code:
'displayParams' => array( 'javascript' =>'onchange="initData();"';,),
Then in the FDC_Aspire.
js I have the
function initData(){
alert("Got Here");
}
Then when I change the date in the Module nothing happens
Rgds
Chris
your problem is that 'displayParams' => array( 'javascript' =>'onchange="initData();"';,), will not work for a date field 
The easiest (but not upgrade safe way to fix it is to edit
include/SugarFields/Fields/Datetime/EditView.tpl
edit the input line to read <input autocomplete="off" type="text" name="{{sugarvar key='name'}}" id="{{sugarvar key='name'}}" value="{$date_value}" title='{{$vardef.help}}' {{$displayParams.field}} size="11" maxlength="10" tabindex="{{$tabindex}}" {{if isset($displayParams.javascript)}}{{$displayParams .javascript}} {{/if}}>
the upgrade safe way to do it is to copy the Datetime field to a new field Datetime_js
then edit as above
Then in EditViewdefs add the line 'type' => 'Datetime_js'
That should fix it
Mike Solomon
Development Manager
Ivy Ltd
www.ivy.ltd.uk]www.ivy.ltd.uk
php version 5.2.6
MySql 5.1.59
Bookmarks