I'm trying to make a form with steps, I mean, so the form does not take up a lot of space, instead of doing it all the way I would like to do 3 or 4 inputs, for example, that the user gives a button next and then more inputs appear. The progress that I have is the following:
The code I have is the following:
MAIN PAGE:
$(document).ready(function() {
$("#abrirform").click(
function(event) {
$("#boton").hide();
contenido = $(".content").load("form1.php");
})
})
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="content">
<h2>Título</h2>
<div id="boton">
<button type="button" id="abrirform" class="btn btn-primary">Abrir formulario</button>
</div>
</div>
The file that is loaded (form1.php) in the div class content when the user clicks on "Open form" is as follows:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<h2>Título</h2>
<div>
<form role="form" action="enviar.php" method="post">
<table id="tabla_form" class="table">
<tr>
<td colspan="2"><label>Esto es un formulario</label></td>
</tr>
<tr>
<td><label>Nombre:</label></td>
<td class="input"><input class="form-control" type="text"></td>
</tr>
<tr>
<td><label>Apellidos:</label></td>
<td class="input"><input class="form-control" type="text"></td>
</tr>
<tr>
<td></td>
<td><button type="button" class="btn btn-primary" id="next">Siguiente</button> 0/5</td>
</tr>
I do not have many doubts in the preparation of the form with steps in itself, but I do not know if when you click on the next button, those variables are stored or not. If possible, I want to store the data of the form with PHP, which is a language I use better. If it is not possible, nothing happens. Another question is that when the user clicks on the next button, imagine that the same content is loaded (a form with a couple of different inputs), I realize that maybe that form is independent of the first, right? p>