1
I have the following field:
<div class="row">
<div class="col-md-6">
<div class="input-group">
<div class="input-group-btn search-panel">
<button type="button" class="btn btn-inverse dropdown-toggle" data-toggle="dropdown">
<span id="search_concept">Filtrar por...</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" style="padding: 10px">
<li><a href="#"><i class="fas fa-caret-right"></i> Nome</a></li>
<li><a href="#"><i class="fas fa-caret-right"></i> Mês e ano</a></li>
<li class="divider"></li>
<li><a href="#"><i class="fas fa-caret-right"></i> Todos</a></li>
</ul>
</div>
<input type="text" class="form-control" name="Nome" placeholder=" Filtrar por nome">
<input type="date" class="form-control" name="Data" placeholder=" Filtrar por data">
<input type="text" class="form-control" name="Todos" placeholder=" Filtro por todos os registros">
<input type="text" class="form-control" name="" placeholder=" Selecione o filtro ao lado">
<span class="input-group-btn">
<button class="btn btn-inverse" type="button"><i class="fas fa-search"></i></button>
</span>
</div>
</div>
</div>
Jquery
<script>
$(document).ready(function(e){
$('.search-panel .dropdown-menu').find('a').click(function(e) {
e.preventDefault();
var param = $(this).attr("href").replace("#","");
var concept = $(this).text();
$('.search-panel span#search_concept').text(concept);
$('.input-group #search_param').val(param);
});
});
</script>
I would like to make sure that when selecting the Month and Year option, replace the Name field with the Date field, if you select the All option, change to the All field and if you do not select the filter, a message appears asking you to select the desired filter. How can I do that?
What is the Date field?
– Sam
What would this substitution look like? Where is the other field?
– GeekSilva
Hello guys. Sorry. I made a change in my post.
– user24136
In your case, you are in trouble where exactly? would it be time to select the item in the dropdown? or can you already get the click of the item correctly?. If you get the click you may use "Nth-Child()" "$('. search-panel . dropdown-menu li:Nth-Child(1)'). click(Function(e)" Where the number within the Nth-Child() parenthesis refers to the DOM element, so I believe you can check the click. Then just change the input placeholder.
– Paulo Felipe Martins
Hello Paul. Actually I am not able to do this exchange of fields, IE, each option appears its respective field.
– user24136
But everyone’s showing up at the same time
– Sam
It would not be the case if you give a display: None fields you do not want to appear and when clicking for example the month button, it hide the others and show only the month.
– Paulo Felipe Martins