On load, I am able to set the text value.
But set value does not work when code is triggered by a dropdown change event. Am sure that dropdown change event had been triggered as function was able to change the text of another single line field.
Sample code:
$(document).ready(function()
{
var activity = SPUtility.GetField('Going');
var showOrHide = function()
{
var activity = activity.GetValue();
var DL_sys_time = SPUtility.GetField('Time');
if (activityVal == 'Yes')
{
SPUtility.ShowSPField('Time');
DL_sys_time.setValue('8pm');
}
else
{
SPUtility.HideSPField('Time');
DL_sys_time.setValue('');
}
};
$(activity.Dropdown).on('change',showOrHide);
}
)
I am using SPUtility.js (Vers: 0.14.2) downloaded from http://sputility.codeplex.com/
Realised that there are typo in my code above and amended some parts for troubleshooting:
$(document).ready(function()
{
var activity = SPUtility.GetField('Going');
var showOrHide = function()
{
var activity = activity.GetValue();
var DL_sys_time = SPUtility.GetField('Note');
if (activityVal == 'Yes')
{
SPUtility.ShowSPField('Note');
DL_sys_time.setValue('Yes');
}
else
{
SPUtility.HideSPField('Note');
DL_sys_time.setValue('No');
}
};
showOrHide();
$(activity.Dropdown).on('change',showOrHide);
}
)
So when the form loads, the field 'note' is hidden. When I change the value of 'Going' to "Yes", 'Note' field is shown, but the text shown is "No".