Sharepointサイトのドロップダウンボックスの値に基づいてフィールドを表示および非表示にするためのjavascriptがあります。私の2番目のIf文は正常に動作しますが、何らかの理由で最初の文がうまく動作しません。私は単純な構文エラーがない場合誰も見ることができます。これで2日を過ごしました。新鮮な目が助けになると思います。Sharepoint JScriptのif文が実行されていない
$(document).ready(function() {
// Get a single select dropdown field
var SubTypeField = SPUtility.GetSPField('Sub Type');
var IssueTypeField = SPUtility.GetSPField('Issue Type');
// create a function to show or hide Field based on Drop Down values value
var showOrHideField = function() {
var SubTypeFieldValue = SubTypeField.GetValue();
var IssueFieldValue = IssueTypeField.GetValue();
// Hide the field if the selected value is Ergonomic
if (SubTypeFieldValue === 'Ergonomic'){
SPUtility.HideSPField('Other Description');
}
else {
SPUtility.ShowSPField('Other Description');
}
if(IssueFieldValue === 'Incident'|| IssueFieldValue === 'Close Call'|| IssueFieldValue === 'Observation') {
SPUtility.HideSPField('Type of injury sustained');
SPUtility.HideSPField('Cause of lost time/injury or first aid');
SPUtility.HideSPField('Was medical treatment necessary');
SPUtility.GetSPField('Type of injury sustained').SetValue('');
SPUtility.GetSPField('Cause of lost time/injury or first aid').SetValue('');
SPUtility.GetSPField('Was medical treatment necessary').SetValue('No');
}
else {
SPUtility.ShowSPField('Type of injury sustained');
SPUtility.ShowSPField('Cause of lost time/injury or first aid');
SPUtility.ShowSPField('Was medical treatment necessary');
}
};
// run at startup (for edit form)
showOrHideField();
// make sure if the user changes the value we handle it
$(IssueTypeField.Dropdown).on('change', showOrHideField);
$(SubTypeField.Dropdown).on('change', showOrHideField);
});