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

Question

Question

Conditionally hide accept reject

asked on September 8, 2017

I want to prevent users for "accidentally" clicking the wrong button, Accept or Reject in a form.  Is there away to conditionally display the appropriate button based on another field's selection.  So for example I would add a drop down or radio button field with the accept and reject options then based on that selection display the appropriate form action button so it is a two step action rather than one.

0 0

Answer

SELECTED ANSWER
replied on September 8, 2017 Show version history

Hi Scott,

This Answers post details how to hide/show the Approve and Reject buttons based on a radio button input. One small addition to Winston's JavaScript that you'll need is to hide the Approve and Reject buttons by default:

  $(".action-btn.Approve").hide();
  $(".action-btn.Reject").hide();

With a drop-down field that would look like:

$(document).ready(function () {
  $(".action-btn.Approve").hide();
  $(".action-btn.Reject").hide();
  $("#q2").on("change", function() {
    if($('#q2 select').val()=='Approve') {
  	$(".action-btn.Reject").hide();
        $(".action-btn.Approve").show();
  	}
   	 if($('#q2 select').val()=='Reject') {
    	$(".action-btn.Approve").hide();
       	$(".action-btn.Reject").show();
   	 }
	});
});

Although - this is a rather odd way to create a two-step action, and I would recommend Raul's suggestion or just have a required confirmation checkbox/field.

2 0

Replies

replied on September 8, 2017

One thing that you can try is alerting the user that they are about to Reject the form. That would make it a two step process.

Plug this into your JavaScript section

$( document ).ready(function() {

$(document).on('click', '.Reject', ConfirmForm);
    
function ConfirmForm(){
  
      return confirm("Are you sure you want to Reject the form? Click OK to continue or Cancel to abort.");
}

});

 

1 0
replied on September 8, 2017

They both worked perfectly...now I get to pick from two solutions.....Thank you.

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

Sign in to reply to this post.