Page 1 of 1

Available choices in Dropdown

Posted: 21 Sep 2017
by TonyDuke
I am trying to limit the available choices in a single choice field on a specific form set, I have tried the following but they don't seem to do anything...

Code: Select all

fd.field('Follow_x0020_up_x0020_Action').control()._el().find('select option:eq(1)').hide();
and

Code: Select all

fd.field('Follow_x0020_up_x0020_Action').control()._el().find('select option[value="Book an Appointment"]').hide();

Help Appreciated.
Thanks

Re: Available choices in Dropdown

Posted: 21 Sep 2017
by Nikita Kurguzov
Hello, Tony!
Try it out from the console. I've tried your first code snippet and it worked just fine for me, perhaps the name of the field is not right? And is it a regular dropdown choice menu or some more specific field, e.g. a lookup or something similar?

Re: Available choices in Dropdown

Posted: 21 Sep 2017
by TonyDuke
Hi Nikita,

I've double checked the name and copied and pasted it from the Forms Designer to ensure it is correct, it is definitely just a regular single choice field. If I enter either of the above into the console it returns

Code: Select all

[object Object]{0: HTMLOptionElement {...}, context: Document {...}, jquery: "1.11.3", length: 1, prevObject: Object {...}, selector: ".fd_field[f..."}
If that means anything to you?

Thanks again

Re: Available choices in Dropdown

Posted: 21 Sep 2017
by Nikita Kurguzov
Yes, it returns the object that it hides, in case you want to do something else with it. If you check dropdown box again, it shouldn't have this option available anymore. It will not change the selected item though, even if you just removed the selected item from choice.
Choice Field - Before.png
Choice Field - Before.png (19.32 KiB) Viewed 1887 times
Choice Field - After.png
Choice Field - After.png (31.56 KiB) Viewed 1887 times
You can also try remove() instead of hide(), it should also work.

Re: Available choices in Dropdown

Posted: 21 Sep 2017
by TonyDuke
Hi Nikita,

Thanks for the help, for your info changing the code to use remove() did the trick, even pasting the code with hide() into the console then checking did not work, I did it several times from 0-6, there are 7 items in the choice list and it did nothing...

Thanks

Re: Available choices in Dropdown

Posted: 21 Sep 2017
by Nikita Kurguzov
Alright, good to know! Perhaps it's a browser difference, using remove should do the trick in all situations.