0
I’m trying to make a form with multiple windows, but I don’t understand what’s going wrong.
What I want to do is that by clicking the buttons it hides and shows the next form.
UPDATE
I followed the suggestion of @Fonso, but it’s not working yet, including updated my codepen, there also does not work.
$( window ).load(function() {
$('form button').on('click', trataForm);
function trataForm(event) {
event.preventDefault();
var $bloco = $(event.currentTarget).parents('div');
$bloco.removeClass('active');
if($(this).hasClass('next')){
if ($bloco.is(':last-child'))
$(event.currentTarget).parents('form').submit(); //<-aqui
else
$bloco.next().addClass('active');
}else{
if (!$bloco.is(':first-child'))
$bloco.prev().addClass('active');
}
}
});
I’m in Wordpress. I’ve made a plugin that adds the css
and js
. It forces you to make calls within a Function, or $( window ).load
, and for some reason it always falls into the first condition (where I put the comment '<-here'). Someone who knows how to solve this?
Much simpler guy. What if in the last div I want him a Ubmit with all the information?
– Marcius Leandro
@Marciusleandro changed the logic to, instead of sending back to the first block, the last button submit the form.
– Afonso
@afonoso was badly its answer is very good, but still not solved my problem, although it works here in the stack, does not work neither in the code open, nor on my page.
– Marcius Leandro