mardi 24 février 2015

reset multi stepsForm.js (minimal form) and get back to the first step after settimeout

I'm using copdrops stepsForm.js and I modified it in some way. Everything is fine, but as I'm not familiar that much with javascript I couldn't make it back to the first step (first question) after the form has submitted.


this is the codrops script:


http://ift.tt/1juxrF5


and this is the modification I made to reset the form and get back to the first question(step) after being submitted.


http://ift.tt/1zBYQdo


and this is the modified javascript I used and also has been added to the end of codepen's javascript:



var theForm = document.getElementById( 'theForm' );

new stepsForm( theForm, {
onSubmit : function( form ) {
// hide form
classie.addClass( theForm.querySelector( '.simform-inner' ), 'hide' );
var messageEl = theForm.querySelector( '.final-message' );
messageEl.innerHTML = 'Thank you! We\'ll be in touch.';
classie.addClass( messageEl, 'show' );

setTimeout(function(){
form.reset()
}, 2500);
setTimeout(function(){
classie.removeClass( messageEl, 'show' )
}, 3000);
setTimeout(function(){
classie.removeClass( theForm.querySelector( '.simform-inner' ), 'hide' )
}, 3500);
}
} );


I really don't know how to force it back to the first question, because I'm unfamiliar with javascript.


Aucun commentaire:

Enregistrer un commentaire