0
I have an input of type Hidden that takes the name of the menu that was selected that was returning from the application, it can receive (tempos, shutdown, values) After the return of the post, I want the menu that was received in the input to be active (class="tab-pane fade active" I have my form :
<script>
function AdicionarClasseMenuSelecionado(){
var menuatual = document.getElementById('MenuSelecionado').value;
alert(menuatual);
//remove todos os active
$("#aba1").removeClass("active");
$("#aba2").removeClass("active");
$("#aba3").removeClass("active");
//adiciona o active de acordo com o input
$("#andamentos").addClass("active in");
$("#aba2").addClass("active");
}
</script>
<div class="container">
<button type="button" onclick="AdicionarClasseMenuSelecionado()" class="btn btn-default">Teste</button>
<input name="MenuSelecionado" type="hidden" value="andamentos" id="MenuSelecionado">
<form action="#" method="POST" class="form-horizontal" role="form">
<div class="form-group">
<legend>Cadastro Teste</legend>
</div>
<ul class="nav nav-tabs">
<li class="active" id="aba1"><a data-toggle="tab" href="#encerramento">Encerramento</a></li>
<li id="aba2"><a data-toggle="tab" href="#andamentos">Andamentos</a></li>
<li id="aba3"><a data-toggle="tab" href="#valores">Valores</a></li>
</ul>
<div class="tab-content">
<div id="encerramento" class="tab-pane fade active">
<h3>Encerramento</h3>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div id="andamentos" class="tab-pane fade ">
<h3>Andamentos</h3>
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam.</p>
</div>
<div id="valores" class="tab-pane fade ">
<h3>Valores</h3>
<p>Eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</p>
</div>
</div>
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</form>
</div>
It goes back to the initial pq after sending the form the page reloads, then back to the initial tab.
– LeAndrade
You can post the code so we can run tests and find a solution?
– user60252
You can after post the form you can put the class . active in the tab that interests you how much you are building the server side tab.
– Jorge Costa
@Leocaracciolo, I added the hmtl code with a form, after the post, I want to keep the same tab open
– Harry
@Jorgecosta, how can I return the form with the same tab open? thank you
– Harry
What is the server-side language
– Jorge Costa
@Jorgecosta, Asp.net webformes,
– Harry
You can post the code
– Jorge Costa
@Jorgecosta, I posted the code, basically it just records the form
– Harry
@Leocaracciolo, I simplified my question, see, I get a content in my input, I want the menu to receive the class according to what I’m getting in this input
– Harry
@Leocaracciolo, the top code works, I can add the class where I need it, but I wanted to add the class dynamically
– Harry