Can I programmatically check the options of a select field?
e.g. whether the options are equal to an empty array?
This question has an accepted answers - jump to answer
By "check" do you mean read the currently selected values? If so, then yes - the field().val() method will get you the currently selected value(s).
No, I mean the options that the user can choose from with the select field. I set them dynamically and it may happen that the user cannot select anything because there are no options available.
@allan , what can I do about this please?
A ) where are your select options coming from?
B ) what do you want to show the user if there are no options?
a) ajax call to server script
b) customized message in Editor window
Would like to check whether there are no options and then display the message. Right now I can't do the check and ALWAYS have to show a message like "in case your contract only comprises 'productxyz' you will not be able to select an option".
Oh - you want to "check what values are in the select field"?
In that case use field().input() with a little jQuery to get the options:
that will give you a jQuery object of the option elements in the select element.
thanks a lot!!!
It looks like you're new here. If you want to get involved, click one of these buttons!
DataTables designed and created by SpryMedia Ltd.
© 2007-2018 MIT licensed. Our Supporters.
SpryMedia Ltd is registered in Scotland, company no. SC456502.