I have a dropdown list contain values, last value is called "Others" when its selected i want to show a new textbox under the field and if its not selected it should be hidden.
I have followed this tutorial: SPUtility
After following the tutorial step by step i get an error in the console:
Uncaught Unable to get a SPField named Suppliers
Since Suppliers column is already there and i mentioned it in the code in the right way, and i have created another column for the textbox called "Other Title".
This is the code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="/sites/devsite/Style%20Library/sputility.js"></script>
<script>
$(document).ready(function ()
{ // Get a the choice field
var choiceField = SPUtility.GetSPField('Suppliers');
// Hide the target fields in form load
SPUtility.GetSPField('Other Title').Hide();
// create a function to show or hide a field based on the selected choice Field value
var ShowHideField = function() {
var selectedFieldValue = choiceField.GetValue();
// Hide the 'Other Title' field if the selected value is 'Other'
if(selectedFieldValue != 'Others') {
SPUtility.GetSPField('Other Title').Hide(); }
else { SPUtility.GetSPField('Other Title').Show(); } };
// attach the function to choice field
$( choiceField.Dropdown).on('change', ShowHideField); });
</script>
And here is still showing even when i select other value than "Others":
The type of the list is Classic Experience so its possible to achieve it ? What i am doing wrong ?
Thank you!
List Settings-->Advance Settings-->List experience (Set to 'Classic experience')
.