How to check the options of a select field
How to check the options of a select field
Can I programmatically check the options of a select field?
e.g. whether the options are equal to an empty array?
https://editor.datatables.net/reference/field/select
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
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).Allan
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?
@rf1234 :
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.Allan
thanks a lot!!!