You are viewing limited content. For full access, please sign in.

Question

Question

checkbox .attr('disabled', true); causes it to UNcheck itself

asked on July 18, 2018

I am using the following javascript to make 2 checkboxes read-only in specific steps of my process.  I am using the same form in all of my steps.  Step 66 is my Processing step.  The problem is that if I check one of the boxes in my Review step, then reject it back to Processing, and then send it back to Review again, when it hits review the box is UNchecked!

If I comment out this code the box stays checked, but of course then this field is editable in the Processing step and I want it to be read only.

$(document).ready(function() { 
if($('input[name="stepid"]').val() =="1" || $('input[name="stepid"]').val() =="66")  
{
  $('#Field400-0').attr('disabled', true);
  $('#Field400-1').attr('disabled', true);
}
});

What am I doing wrong?

Thanks in advance!

0 0

Answer

SELECTED ANSWER
replied on July 18, 2018 Show version history

It might be losing the value on submission because it is disabled. You could try attaching an event handler to the submit button that re-enables the field when it is clicked.

For example,

  $('.Submit').click(function(){
    $('.checkBoxTest input').removeAttr('disabled');
  });

This way the field(s) will be disabled while the user is working on the form, but as soon as they submit it the field will be re-enabled right before the submission to make sure the value is saved.

I've seen situations in the past where Forms will ignore/lose the values of disabled fields upon submission, so this would prevent that from happening.

0 0

Replies

replied on July 18, 2018

Jason,

Thanks, again, for the help! That fixed it!  Of course I had to put your code in a document ready function, that threw me at first.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.