Available choices in Dropdown

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
User avatar
TonyDuke
Posts: 71
Joined: Mon Sep 11, 2017

21 Sep 2017

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

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

21 Sep 2017

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?
Cheers

User avatar
TonyDuke
Posts: 71
Joined: Mon Sep 11, 2017

21 Sep 2017

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

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

21 Sep 2017

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 1888 times
Choice Field - After.png
Choice Field - After.png (31.56 KiB) Viewed 1888 times
You can also try remove() instead of hide(), it should also work.
Cheers

User avatar
TonyDuke
Posts: 71
Joined: Mon Sep 11, 2017

21 Sep 2017

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

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

21 Sep 2017

Alright, good to know! Perhaps it's a browser difference, using remove should do the trick in all situations.
Cheers

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests