I am using a SharePoint list in which we are using multiple columns covering different process steps to be filled based on a dropdown selection.
The steps are different depending on the mission selection. I want to be able to show/hide fields column depending on the dropdown selection of the mission.
I have added a code here as an example to showcase what I need to do based on the following:
The mission selection column is called 'Selection' and includes dropdown options: 'Yellow', 'Orange', 'Red', 'Green'.
I worked the code on the following columns: 'Country', 'Animal', 'Fruit', and 'Colour'. However, the code is not working at all. I don't have experience in coding so obviously something is not working out but I am not able to detect the issue, so highly appreciate your support to provide any leads on this.
<script src="/SiteAssets/jquery-3.3.1.js"> </script>
<script src="/SiteAssets/sputility.js"> </script>
<script>
$(document).ready(function () {
//Show/hide columns based on Drop Down Selection
$("select[title='Selection']").change(function () {
var ddlValue = SPUtility.GetSPField('Selection').GetValue();
if (ddlValue == 'Yellow') {
SPUtility.ShowSPField('Country');
SPUtility.ShowSPField('Colour');
SPUtility.HideSPField('Animal');
SPUtility.HideSPField('Fruit');
}
if (ddlValue == 'Orange') {
SPUtility.ShowSPField('Fruit');
SPUtility.ShowSPField('Colour');
SPUtility.HideSPField('Country');
SPUtility.HideSPField('Animal');
}
if (ddlValue == 'Red') {
SPUtility.ShowSPField('Animal');
SPUtility.HideSPField('Country');
SPUtility.HideSPField('Fruit');
SPUtility.HideSPField('Colour');
}
if (ddlValue == 'Green') {
SPUtility.ShowSPField('Colour');
SPUtility.ShowSPField('Animal');
SPUtility.HideSPField('Country');
SPUtility.HideSPField('Fruit');
}
});
});
</script>
https://tenant.sharepoint.com/sites/Mysite/siteassets/...
then try referencing file like:/sites/Mysite/siteassets/jquery-3.3.1.js
. if that doesn't work then try adding complete file URL. You can ensure the files are loaded or not under Sources tab in browser's developer tools. Also, if file is not loaded you will get 404 error in browser's console.