Skip to main content
Nintex Community Menu Bar

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

  • May 27, 2019
  • 4 replies
  • 13 views

dperani
Forum|alt.badge.img+5

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:

2311iC32D9DA6F9A51379.jpg

4 replies

Forum|alt.badge.img+10
  • May 30, 2019
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('');
}
});
}

dperani
Forum|alt.badge.img+5
  • Author
  • Scholar
  • May 30, 2019

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('');
}});


MegaJerk
Forum|alt.badge.img+14
  • Scholar
  • May 30, 2019

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. 


dperani
Forum|alt.badge.img+5
  • Author
  • Scholar
  • May 30, 2019

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