Shmuel
Shmuel

Reputation: 11

Dynamically display "Next" or "Submit" in Gravity Forms

I am creating a form with conditional logic: Option 1: a user will put in just their basic information. Option 2: if they select a checkbox then they will fill in a series of questions in addition to the basic information. I would like that all the questions that will be presented in option 2 to be on page two of the form which will only display accordingly. All this works, the issue is that the "Submit" button is on page two not page one, so in option 1 the user does not see a "Submit" button only a "Next" button. [The next will submit the form but my concern is the text and styling of the button]. I need conditional logic on the Submit button so if option 1 is chosen the button will display a Submit button and if they choose option 2 it will display a next button.

Upvotes: 0

Views: 1687

Answers (1)

Louys Patrice Bessette
Louys Patrice Bessette

Reputation: 33933

Based on the checkbox state, you can change the button's text (its value).
Since you showed no code, here's an minimal example.

$("#more").on("click",function(){
	if ( $(this).prop("checked") ){
		$("#next").val("Next");
	}else{
		$("#next").val("Submit");
	}
});

$("#next").on("click",function(){
	if( $(this).val() == "Submit" ){
		alert("Submit the form now.");
	}else{
		alert("Ask the other questions.");
	}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" id="more"> Check to answer additionnal question<br>
<br>
<input type="button" id="next" value="Submit">

Upvotes: 1

Related Questions