Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
titleCalculated Value Script
linenumberstrue
//Assign a system calculated date based on data entry in another component.
var current = new Date(data.dateSigned);
if(data.signature && current.toString() === 'Invalid Date')
{
    var d = new Date();
    value = d.toLocaleDateString();
}
else
    value = data.dateSigned;


Add state control to check boxes to mimic radio button behavior

This script uses a Text Component (checkState) to preserve the last selected Checkbox Component.  Use two or more checkboxes (this example shows 3) and adjust the script accordingly.

Code Block
languagejs
titleCalculated Value Script
linenumberstrue
//Add state control to checkboxes to mimic radio button behavior.
if(data.check1 === true  && (data.checkState == '2' || data.checkState == '3'))
    {
        value = '1';
        data.check2 = false;
        data.check3 = false;
    }
else if (data.check2 === true && (data.checkState == '1' || data.checkState == '3'))
{
    value = '2';
    data.check1 = false;
    data.check3 = false;
}
else if (data.check3 === true && (data.checkState == '1' || data.checkState == '2'))
{
    value = '3';
    data.check1 = false;
    data.check2 = false;
}
else if (data.check1 === true)
    value = 1;
else if (data.check2 === true)
    value = 2;
else if (data.check3 === true)
    value = 3;