![image](https://community.plumsail.com/uploads/default/original/2X/5/51ac6ec048599fa0cada4923edbd962eb04e3300.png)
This code works exactly for what I need.
if (fd.field('Currently_x0020_CoRE_x0020_123_x').value.indexOf("**Personal Travel**") >= 0) {
// Show field
$(fd.control('Text2').$el).show();
$(fd.field('ProceedRequest').$parent.$el).show();
$(fd.control('CloseButton').$el).hide();
fd.container('Tab1').tabs[1].disabled = false;
However, I also need that if "Personal Travel is not selected as one of the choice, I need this to happen:
// Show field
$(fd.control('Text2').$el).hide();
$(fd.field('ProceedRequest').$parent.$el).show();
$(fd.control('CloseButton').$el).hide();
fd.container('Tab1').tabs[1].disabled = false;
Can you help me please? I tried something but I did not like my solution. Hence, this request for help.
Thank you so much!
Dear @Jamail_Serio,
And why does else not work?
else{
// Show field
$(fd.control('Text2').$el).hide();
$(fd.field('ProceedRequest').$parent.$el).show();
$(fd.control('CloseButton').$el).hide();
fd.container('Tab1').tabs[1].disabled = false;
}
You can also do an opposite check:
if (fd.field('Currently_x0020_CoRE_x0020_123_x').value.indexOf("Personal Travel") < 0) {
// Show field
$(fd.control('Text2').$el).hide();
$(fd.field('ProceedRequest').$parent.$el).show();
$(fd.control('CloseButton').$el).hide();
fd.container('Tab1').tabs[1].disabled = false;
}
I am not sure why both have to have this block though, isn't it the same?
$(fd.control('CloseButton').$el).hide();
fd.container('Tab1').tabs[1].disabled = false;
let me clarify -
what I want to know is when the user selects "Contract..." or "Critical..." or "Rapid..." this is what is going to happen...
$(fd.control('Text2').$el).hide();
$(fd.field('ProceedRequest').$parent.$el).show();
$(fd.control('CloseButton').$el).hide();
fd.container('Tab1').tabs[1].disabled = false;
This is the full code I am using -
function hideOrShowFields() {
if (fd.field('Currently_x0020_CA_20abA_x').value.indexOf("Personal Travel") >= 0) {
$(fd.control('Text2').$el).show();
$(fd.field('ProceedRequest').$parent.$el).show();
$(fd.control('CloseButton').$el).hide();
fd.container('Tab1').tabs[1].disabled = false;
}
else {
$(fd.control('Text2').$el).hide();
$(fd.field('ProceedRequest').$parent.$el).hide();
$(fd.control('CloseButton').$el).hide();
fd.container('Tab1').tabs[1].disabled = true;
}
}
Dear @Jamail_Serio,
You can always check for multiple conditions using either multiple if conditions:
function hideOrShowFields() {
if (fd.field('Currently_x0020_CA_20abA_x').value.indexOf("Personal Travel") >= 0) {
$(fd.control('Text2').$el).show();
$(fd.field('ProceedRequest').$parent.$el).show();
$(fd.control('CloseButton').$el).hide();
fd.container('Tab1').tabs[1].disabled = false;
}
else {
$(fd.control('Text2').$el).hide();
$(fd.field('ProceedRequest').$parent.$el).hide();
$(fd.control('CloseButton').$el).hide();
fd.container('Tab1').tabs[1].disabled = true;
}
if (fd.field('Currently_x0020_CA_20abA_x').value.indexOf("Contract") >= 0) {
//do something
}
else {
//do something else
}
}