I am using jquery-steps to create an "interactive" two/three step form.
One thing I am trying to achieve is to show/hide an additional step after step 2 (which would normally be the final step) which would be the new final step based on the value of a checkbox. If it's checked, step 3 should show up, otherwise the form would submit after step 2. However, I am not sure where to start!
This is what I have so far for the javascript part.
$("#wizard").steps({
headerTag: "h1",
bodyTag: "fieldset",
//transitionEffect: "slideLeft",
onStepChanging: function(event, currentIndex, newIndex)
{
//only apply to first step
if (currentIndex === 0 && ($('#opt1').attr('checked')))
{
$("#wizard").steps("insert", 1, {
title: "Step Title",
content: "<p>Step Body</p>"
});
}
return true;
},
onFinished: function (event, currentIndex)
{
var form = $(this);
form.submit();
},
});
The full form is available on JSFiddle
Hope this updated script helps you. Paste the below code just after
</form>
tag based in the JSFiddle you provided.