pop up alert on check box

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
jpwallace
Posts: 47
Joined: Fri Mar 03, 2017

18 Apr 2017

Morning guys,
I have set up my form so that an alert pops up when I check a Void/Cancel check box.....

fd.field('Void/cancel').change(function() {
alert ('my alert');
});

The problem is that it also issues the alert when I uncheck the box, what am I missing so that the alert only appears when I check the void/cancel box

Cheers

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

18 Apr 2017

Hi,
Check the field value in the handler:

Code: Select all

fd.field('Void/cancel').change(function() {
    if (fd.field('Void/cancel').value()) {
        alert ('my alert');
    }
});

jpwallace
Posts: 47
Joined: Fri Mar 03, 2017

25 Apr 2017

Hi Dmitry,

Following on from this, I changed my form to a check box and for the alert to appear if the check box is ticked. I used....
function setExtendedreasons() {
if (fd.field('Extended').value() =='1') {
$('.Extendedreasons').show();
alert ('You have extended the due date for this task. Please insert your comments in the narrative section under the Task Progress tab.');
} else {
$('.Extendedreasons').hide();
}
}
fd.field('Extended').change(setExtendedreasons);
setExtendedreasons();

The issue I have is that when the form is closed and then reopened the alert pops up before the form opens, what do I need to change in order for the alert to appear just when the box is ticked and not when the form opens??

Many thanks

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

25 Apr 2017

Remove call of the setExtendedreasons on loading the form (last line).

jpwallace
Posts: 47
Joined: Fri Mar 03, 2017

25 Apr 2017

Fantastic, works a treat, thank you

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests