Need help with a expression
Original Post by CHO (Imported from Ardevia Forum)
Dear Ardevia community,
we have a problem with a ardevia expression.
The problem is:
we need to disable more radio buttons from one field depending on changes in fields before.
Example:
if i set the date field to 25.1.2015. (date after 15.1.2015.) i need to disable the radio button for January, etc, for every date.
What would be the command to access just one radio button in a field?
Thanks in advance.
-
Original Post by iryna (Imported from Ardevia Forum)
There are no direct possibility to disable some options of radiobutton field depending on the condition.
But the following trick gives needed result:
1. Select your radiobutton field
2. Open Expression Builder for 'Enabled' control
3. Select 'Function code'
4. Insert the following code example and replace list names with your valuesThe first example disables only one radiobutton for the selected month if day is more than 15:
https://monosnap.com/file/NJFJaEsCVmOfxrgisWVsLulYr7uSj8.pngCode:
if ([[YourDateField]]){ var selectedMonth = [[YourDateField]].getMonth(); var selectedDay = [[YourDateField]].getDate(); if(selectedDay > 15) setTimeout(function(){ jQuery('span[fieldname=YourRadiobuttonField] input[type=radio]')[selectedMonth].disabled = true; },100); } return true;Second example disables all months options that are less than selected date:
https://monosnap.com/file/RBCjthm7vQx1KRCnSvEZP7oZily8KG.pngCode:
if ([[YourDateField]]){ var selectedMonth = [[YourDateField]].getMonth(); var selectedDay = [[YourDateField]].getDate(); setTimeout(function(){ for(var i=0;i<=selectedMonth;i++) { if(i!=selectedMonth || selectedDay > 15) jQuery('span[fieldname=YourRadiobuttonField] input[type=radio]')[i].disabled = true; } },100); } return true;For the dropdown choice field, the code should be as following:
Code:
if ([[YourDateField]){ var selectedMonth = [[YourDateField]].getMonth(); var selectedDay = [[YourDateField]].getDate(); if(selectedDay > 15) setTimeout(function(){ jQuery('span[fieldname=YourDropdownField] option')[selectedMonth].disabled = true; },100); } return true;0
Please sign in to leave a comment.
Comments
1 comment