How to make my script loop?

0

I created the following script:

$(".circulo").click(function() {
  $('form').show();
});


$("#next").click(function() {
  $("#test1").hide();
  $("#test2").show();
});

$("#back").click(function() {
  $("#test1").show();
  $("#test2").hide();
});

for the following form:

What happens here is there is a form that is in display:none , when you give a circle this is seen, then the form is divided into two parts the first shows you two inputs, when you give next puts you the first group in hide and the second in show, and in the second there is one that lets you go back. The issue is that it only works once, then no longer. And also I have to implement a function in the script, which when you submit, put the whole form in hide, and I do not know very well if you use window.close(); . Can someone help me out?

P.D: The functional code is here

    
asked by Dario B. 09.09.2018 в 20:57
source

1 answer

1

I do not know if it works for something but ..., if the button instead of submit you do this

<div class="body">
   <div class="circulo">
   </div>
   <div id='head'>
      <form name="mi_formulario" method="post">
         <div id="test1">
            <div>
               <label for="avatar">Profile picture:</label>
               <input type="file"
                  id="avatar" name="avatar"
                  accept="image/png, image/jpeg" />
            </div>
            <div>
               <label for="msg">Message:</label>
               <textarea id="msg" name="user_message"></textarea>
            </div>
            <a href="#">
               <div id="next">
                  next
               </div>
            </a>
         </div>
         <div id="test2">
            <div>
               <label for="name">Name:</label>
               <input type="text" id="name" name="user_name">
            </div>
            <div>
               <label for="mail">E-mail:</label>
               <input type="email" id="mail" name="user_mail">
            </div>
            <div class="button">
               <button id="submit_button" onclick="send_form();">Send your message</button>
            </div>
            <a href="#">
               <div id="back">
                  back
               </div>
            </a>
         </div>
      </form>
   </div>
</div>

What I have done is to name the form and remove the tipe submit button and add a javascript function that is as follows.

function send_form(){
    document.forms.mi_formulario.submit();
    $('form').hide();
}

is what happens to me right now, surely it can be made simpler but good, I hope this helps you. Greetings.

    
answered by 10.09.2018 / 09:48
source