OK I got it to work!
It seems it didn't like the == operator...
So I changed the function to fn-If(fn-Equals(Decision Type, 'Meeting'), 'Generate Documents with Notice', 'Generate Documents')
And also add a word-wrap: break-word; CSS style
EDIT:
Back to square one, the label value is static and doesn't seem to change regardless of the Decision Type radio-button value!
Is there a way to get it to change on the fly??
Hi,
I've been having a go with this and I reckon the only way this could work would be to have 2 buttons, one on top of the other, that you can show/hide depending on the value selected in the named radio button control.
Jan
Hey Jan,
The problem with that solution is that I want to make further fn-If conditions if the decision type == 'Meeting', e.g. check the dates and decide if it's a Short Notice Meeting etc, and don't want to have to add additional buttons..!
I would also be happy if I could detect (via Javascript) the .change() event of the Calculated field and then assign its value to the button's label, but unfortunately the .change() event IS NOT TRIGGERED for labels!
Hi,
Could you move the logic from the calculated field to script? If you attach a change event to your select control (JavaScript id of jsDROPDOWN1) then you can change the button label depending on the value chosen.
NWF$(document).ready(function () {Â Â Â
   NWF$("#" + jsDROPDOWN1).change(function(){
       var replacetext = '';
       switch (NWF$(this) 0].value)
       {
        case 'None':
     replacetext = 'One';
     break;
 default:
     replacetext = 'Two';
     break;
};
NWF$(".myButtonLabel input").prop('value', replacetext);
});
});
Jan
Hey Jan,
I wanted to avoid a JS-bound solution, as the If conditions are dependent on multiple controls (2 datetime pickers + 1 radio button, for now) and I didn't want to have to add .change() events to each control...
(the acceptable change I mentioned before was for a single .change() event, on the calculated field).
Here is what I have on the calculated field right now (which works correctly):
If(DecisionType == 'Meeting', If(isNullOrEmpty(ActualNoticePeriod), 'With No Notice', If(ActualNoticePeriod < NoticePeriodPerRegulation, 'With Short Notice', 'With Notice')), '')
Hi,
I've got this working using the calculated field now, if you give the calculated field a JavaScript id of jsCalculatedField then putting a delay in the change event of the select control does the trick.
NWF$(document).ready(function () {Â Â Â
   NWF$("#" + jsDROPDOWN1).change(function(){
var delay=1000;
setTimeout(function() {Â
   var replacetext = NWF$("#" + jsCalculatedField)a0].defaultValue;
          NWF$(".myButtonLabel input").prop('value', replacetext);
       }, delay);
  });
});
Jan
But you're still relying on the .change() event of the dropdown list...
What happens if the dropdown remains the same but the datetimepicker value changes?
The calculated value will change but your button won't!
If you apply a CSS class to each control you want to trigger the button label change then you can do it, I've used a class of changeTrigger. You'll need to get hold of each type of control in script and attach an appropriate event to it, sample code below:
NWF$(document).ready(function () {Â Â
//select controls
NWF$(".changeTrigger select").change(function(){
   setLabel();
});
//date pickers
NWF$(".changeTrigger").find("input.nf-date-picker").each(function() {
   NWF$(this).blur(function(){
       setLabel();
   });
});
});
function setLabel() {
var delay=1000;
setTimeout(function() {Â
var replacetext = NWF$("#" + jsCalculatedField) 0].defaultValue;
NWF$(".myButtonLabel input").prop('value', replacetext);
}, delay);
}
Jan
Hey Jan,
I ended up going with a completely different approach, only showing the information on the Calculated field and keeping the button label static, but I like your approach with the css classes!
If in the future you think of a way to detect the .change() event on a calculated (label) field, however, please let me know! that would be really helpful!