cancel
Showing results for 
Search instead for 
Did you mean: 
dperani
Nintex Newbie

Need help with jQuery to clear section fields if section yes/no unchecked

I have three yes/no boxes on my form (Nintex and Sharepoint 2013)  that once unchecked it clears the fields in that section so that it does not populate the list columns with that data.  I have used the following jQuery for the first yes/no in the Custom Javascript area of form:

NWF$(document).ready(function () {
  var optELA= NWF$("#" + chkELA);  

optELA.change(function(){   

if (NWF$('#'+chkELA).attr('checked')==false){
      NWF$('#'+datLeaveStart).val('');
      NWF$('#'+datLeaveEnd).val('');
      NWF$('#'+radAbsenceType).val('');
      NWF$('#'+txtAbsenceComments).val('');
   }
 });
});

It is not working. 

The sections look as follows if it helps put into perspective:

Status form.jpg

Labels: (1)
0 Kudos
Reply
4 Replies
sojanm
Nintex Newbie

Re: Need help with jQuery to clear section fields if section yes/no unchecked

NWF$(document).ready(function () {
//jsvoptELA - is the javascript variable for optELA
NWF$('#'+ jsvoptELA).change(function() {OnELAChnage();});
});

function OnELAChnage() {
if(!NWF$('#' + jsvoptELA).prop('checked')){
NWF$('#'+datLeaveStart).val('');
NWF$('#'+datLeaveEnd).val('');
NWF$('#'+radAbsenceType).val('');
NWF$('#'+txtAbsenceComments).val('');
}
});
}
0 Kudos
Reply
dperani
Nintex Newbie

Re: Need help with jQuery to clear section fields if section yes/no unchecked

I am a step closer the code below clears the date (start with dat) fields but does not clear the choice/radio buttons(start with rad) nor the text fields(start with txt):

NWF$('#'+chkELA).change( function(){$('#'+datLastShift).val('');
$('#'+datRTW).val('');
$('#'+datTermination).val('');
$('#'+radTermType).prop('checked', false);
$('#'+txtTermComments).val('');
}});

0 Kudos
Reply
Automation Master
Automation Master

Re: Need help with jQuery to clear section fields if section yes/no unchecked

The code you most recently posted is incorrectly closed. 

NWF$('#' + chkELA).change(function() {
  $('#' + datLastShift).val('');
  $('#' + datRTW).val('');
  $('#' + datTermination).val('');
  $('#' + radTermType).prop('checked', false);
  $('#' + txtTermComments).val('');
});

 

Your code had an extra Curly Bracket at the end. 

0 Kudos
Reply
dperani
Nintex Newbie

Re: Need help with jQuery to clear section fields if section yes/no unchecked

Thank you for noticing that!  I removed the extra curly bracket and it did not make a difference

0 Kudos
Reply