Hello,
I am trying to hide one field deping on my dropdown choice.
I have this code but nothing is happening.
function showHideOther() {
if(fd.field('ProductType').value == 'Other'){
$(fd.field('ArtCodeProduct1').$parent.$el).hide();
}
else {
$(fd.field('ArtCodeProduct1').$parent.$el).show()
}
}
fd.spRendered(function () {
//сalling the function on form load
showHideOther();
//Call the function when the field value changes
fd.field('ProductType').$on('change', showHideOther);
});
So what has to happen if Other or Other 2 is selected then hide ArtCodeProduct1
Dear @Lukas_Sliuzas,
It should technically work. Try the following and see what browser's console says:
function showHideOther() {
console.log(fd.field('ProductType').value);
if(fd.field('ProductType').value == 'Other'){
$(fd.field('ArtCodeProduct1').$parent.$el).hide();
}
else {
$(fd.field('ArtCodeProduct1').$parent.$el).show()
}
}
fd.spRendered(function () {
//сalling the function on form load
showHideOther();
//Call the function when the field value changes
fd.field('ProductType').$on('change', showHideOther);
});
Post a screenshot here.
Hello,
Would there be an issue if I am running this just in Plumsail form and not on SharePoint form?
Dear @Lukas_Sliuzas,
Yes, but you can just change it to this and it should work:
function showHideOther() {
console.log(fd.field('ProductType').value);
if(fd.field('ProductType').value == 'Other'){
$(fd.field('ArtCodeProduct1').$parent.$el).hide();
}
else {
$(fd.field('ArtCodeProduct1').$parent.$el).show()
}
}
fd.rendered(function () {
//сalling the function on form load
showHideOther();
//Call the function when the field value changes
fd.field('ProductType').$on('change', showHideOther);
});
Ahh now it worked, thanks a lot!
Now I run into another issue if it will be an issue. I have for example 10 fields and I hide first 5 fields, will other 6-10 slide up automatically?
Dear @Lukas_Sliuzas,
Using this method, yes, they will slide up.