Page 1 of 1

Have a check box enable an alert/a read only field and hide a field.

Posted: 27 Apr 2017
by jpwallace
On my edit form I have a due date field, an extend due date field and a reasons field, I would like that when the form loads the due date is read only and that when the extend due date tick box is ticked an alert appears, the reasons why field appears and the due date is no longer read only.... here is what I have so far, the script below shows the alert when the check box is ticked, the hidden field is shown but when the form loads the due date is not read only, i have 2 check the box, uncheck and then check again for it to work.I know there is a little missing from the below script, plus also is there a better more cleaner way to write it??


//show or hide the due date extension reasons
function setTMSreasons() {
if fd.field('Extended').value() == '1') {
$('.TMSreasons').show();
} else {
$('.TMSreasons').hide();
}
}
fd.field('Extended').change(setTMSreasons);
setTMSreasons();

//Alert for extended due date
function setExtendedreasons() {
if (fd.field('Extended').value() == '1') {
alert ('You have extended...........');
}
}
fd.field('Extended').change(setExtendedreasons);

//read only for due date
function setDue_x0020_Date() {
if (fd.field('Extended').value() =='1') {
fd.field('Due_x0020_Date').readonly(false);
} else {
fd.field('Due_x0020_Date').readonly(true);
setExtended();

Re: Have a check box enable an alert/a read only field and hide a field.

Posted: 28 Apr 2017
by Dmitry Kozlov
I cannot find definition of the setExtended function that you call at the end.