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

Question

Question

radio button not holding its value between tasks

asked on February 2, 2018

I have a process where all the manager reviews are done on one form. I'm using JavaScript to hide, mark read only, and/or, clear the fields depending on which task the process is at.

Hide: so managers don't accidentally fill in the wrong section.

Read Only: so managers don't edit other managers information by accident.

Clear Fields: in case a manager sends it back as not belonging to them it clears the fields so the next manager doesn't have to delete and then enter their new information.

The process was working until I added the clear fields code. It will clear the fields but when I select an option for the radio field (Approved/Not Approved/Not My Unit) it will show the selection and allow me to submit the form (it's marked as a required field) but when it goes to route it to the next task it's not recognizing that one of those options was selected and so it takes the default path.

Any help with the code to get this working would be much appreciated!

    if ($('input[name="stepid"]').val() == "30") {
         $('.clearUnit input, .clearUnit textarea, .clearUnit select').each(function() {clearSection($(this), true);});
    } else if ($('input[name="stepid"]').val() == "112") {
         $('.clearUnit input, .clearUnit textarea, .clearUnit select').each(function() {clearSection($(this), true);});
    } else if ($('input[name="stepid"]').val() == "102") {
         $('.clearL2Unit input, .clearL2Unit textarea, .clearL2Unit select').each(function() {clearSection($(this), true);});
    } else if ($('input[name="stepid"]').val() == "80") {
         $('.clearDirector input, .clearDirector textarea, .clearDirector select').each(function() {clearSection($(this), true);});
    } else {
        //do nothing
    }

My code.txt (7.33 KB)
0 0

Answer

SELECTED ANSWER
replied on February 12, 2018

Hi Cassandra,

I checked your custom script, in your function clearSection there was "f.val("");" which cleared the value on the checkbox/radio button fields. Doing so would break the field so the submitted value was blank.

The value attribute should not be changed for checkbox/radio button fields. You only need to set it as unselected.

1 0

Replies

replied on February 10, 2018

Hi Cassandra,

After form submission, can you check the instance detail page and see if the radio button has value submitted?

If there is value submitted, then the cause is that the gateway route is wrong; if there is no value, then it might be custom script issue which blocks field value from being submitted.

0 0
replied on February 12, 2018

Hi Rui - the value is showing blank after submission for both radio buttons and check marks actually.

Here is one of the instances:

         

In the first task, I selected "choice 1" in Section 2.

          

 

In the next task, the javascript clears all fields in Section 2 on document.ready(), then I selected "choice 3" and it allowed me to Submit the form, but doesn't save the selection.

         

Instance Variables:

            

0 0
SELECTED ANSWER
replied on February 12, 2018

Hi Cassandra,

I checked your custom script, in your function clearSection there was "f.val("");" which cleared the value on the checkbox/radio button fields. Doing so would break the field so the submitted value was blank.

The value attribute should not be changed for checkbox/radio button fields. You only need to set it as unselected.

1 0
replied on February 14, 2018

Thanks - that pointed us in the right direction. We changed it to this and its now working:

if ($('input[name="stepid"]').val() == "77") {
  $('.clear input, .clear textarea').each(function(){clearSection($(this), true);});
}
  
if ($('input[name="stepid"]').val() == "77") {
  $('.clear input.singleline, .clear input.calendar, .clear textarea, .clear select').each(function(){clearSectionTwo($(this), true);});  
}
  
function clearSection(e,t){
	if(t){
		// Clear radio and checkbox elements
                e.prop('required', false).change();
                e.prop('checked', false).change();
	} else {
		// Do nothing
	}
}
  
function clearSectionTwo(e,t){
	if(t){
		// Clear singleline, multiline, calendar, dropdown elements
                e.val("").change();
	} else {
		// Do nothing
	}
}  

 

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

Sign in to reply to this post.