3
I’m implementing a step-by-step form (Wizard) and I’m using the CSS of the gathering.
Basically I use the Model Bootstrap so that the user cannot log into your account without first completing certain steps.
CSS:
.nav-wizard > li {
float: left;
}
.nav-wizard > li > a {
position: relative;
background-color: #eeeeee;
}
.nav-wizard > li > a .badge {
margin-left: 3px;
color: #eeeeee;
background-color: #428bca;
}
.nav-wizard > li:not(:first-child) > a {
padding-left: 34px;
}
.nav-wizard > li:not(:first-child) > a:before {
width: 0px;
height: 0px;
border-top: 20px inset transparent;
border-bottom: 20px inset transparent;
border-left: 20px solid #ffffff;
position: absolute;
content: "";
top: 0;
left: 0;
}
.nav-wizard > li:not(:last-child) > a {
margin-right: 6px;
}
.nav-wizard > li:not(:last-child) > a:after {
width: 0px;
height: 0px;
border-top: 20px inset transparent;
border-bottom: 20px inset transparent;
border-left: 20px solid #eeeeee;
position: absolute;
content: "";
top: 0;
right: -20px;
z-index: 2;
}
.nav-wizard > li:first-child > a {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.nav-wizard > li:last-child > a {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.nav-wizard > li:hover > a {
background-color: #d5d5d5;
}
.nav-wizard > li:hover > a:before {
border-right-color: #d5d5d5;
}
.nav-wizard > li:hover > a:after {
border-left-color: #d5d5d5;
}
.nav-wizard > li.active > a,
.nav-wizard > li.active > a:hover,
.nav-wizard > li.active > a:focus {
color: #ffffff;
background-color: #428bca;
}
.nav-wizard > li.active > a:after {
border-left-color: #428bca;
}
.nav-wizard > li.active > a .badge {
color: #428bca;
background-color: #ffffff;
}
.nav-wizard > li.disabled > a {
color: #999999;
}
.nav-wizard > li.disabled > a:hover,
.nav-wizard > li.disabled > a:focus {
color: #999999;
text-decoration: none;
background-color: transparent;
cursor: not-allowed;
}
.nav-wizard.nav-justified > li {
float: none;
}
.nav-wizard.nav-justified > li > a {
padding: 10px 15px;
}
@media (max-width: 768px) {
.nav-wizard.nav-justified > li > a {
border-radius: 4px;
margin-right: 0;
}
.nav-wizard.nav-justified > li > a:before,
.nav-wizard.nav-justified > li > a:after {
border: none !important;
}
}
To test I created a very simple HTML:
div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<ul class="nav nav-wizard">
<li class="active"><a href="#" onclick="altera_form(1);" >Idioma</a></li>
<li><a href="#" onclick="altera_form(2);" >Profile</a></li>
<li><a href="#" onclick="altera_form(3);" >NIF</a></li>
</ul>
</div>
<div id="modal-body" class="modal-body">
<!-- AQUI FICAM OS CAMPOS DO FORMULÁRIO -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
O Javascript:
<script type="text/javascript">
//cria o model
$('#myModal').modal({
backdrop: 'static',
keyboard: false
});
//Ativa a TAB selecionada
$('.nav-wizard').on('click','li', function(){
$(this).addClass('active').siblings().removeClass('active');
});
//função para alterar o conteúdo do modal-body
function altera_form(num) {
var elems = document.getElementsByTagName('li');
for (i in elems) {
if(elems[i].className=='active')
document.getElementById('modal-body').innerHTML = "ola"+num;
}
}
</script>
How can I pass (via Javascript or otherwise) the PHP form fields whenever I change TAB’s Wizard?
Sample image:
Note: I added the Bootstrap tag because I’m working with Bootstrap and if anyone knows a better way to do that.
Why don’t you leave all the fields on the screen and hide them as you go through TAB? I think it would be the simplest solution...
– Lucas Venturella
I already have this working, that’s exactly what I did. When I have time I will put an answer
– Jorge B.