1
Good night,
I have a page with 3 Divs and within each div has a different form, I leave all the Divs hidden and make them appear as the value selected in a first combobox(select) option that is visible. When the hidden div appears, it comes with another option select and a button for the user to do the search, only that every click on the Divs button with the selected search option disappears, and did not want them to disappear, wanted when clicking the button, the combobox div together with the selected div was visible and with its values selected showing the result, until the person selects another option and makes another search...someone can help me: example:
I keep them hidden here:
<script>
$(document).ready(function() {
$('#div1').hide();
$('#div2').hide();
$('#div3').hide();
$('#comboBox').change(function() {
if ($('#comboBox').val() == 'Boletos') {
$('#div1').show();
$("#div2").hide();
$('#div3').hide();
} else if ($('#comboBox').val() == 'Folhas') {
$('#div1').hide();
$("#div2").show();
$('#div3').hide();
} else if ($('#comboBox').val() == 'Guias') {
$('#div1').hide();
$("#div2").hide();
$('#div3').show();
} else {
$('#div1').hide();
$("#div2").hide();
$('#div3').hide();
}
});
});
</script>
combobox that selects which div should appear, as you select her option the div is visible:
<select id="comboBox" name="comboBox">
<option>Selecione sua opção aqui</option>
<option value='div1'>div1</option>
<option value='div2'>div2</option>
<option value='div3'>div3</option>
</select>
And as you select the value Divs appear:
<form action="div1.php" method="POST">
<div id="div1">
<select id="combo1" name="combo1">
<option value='selecione'>Selecione sua opção aqui</option>
<option value='Pagamento 1'>Pagamento 1</option>
<option value='Pagamento 2'>Pagamento 2</option>
</select>
<button type="submit" id="btn1" value="btn1">Buscar</button>
</div>
</form>
<form action="div2.php" method="POST">
<div id="div2">
<select id="combo2" name="combo2">
<option>Selecione sua opção aqui</option>
<option value='Folha 1'>Folha 1</option>
<option value='Folha 2'>Folha 2</option>
</select>
<button type="submit" id="btn2" value="btn2">Buscar</button>
</div>
</form>
<form action="div3.php" method="POST">
<div id="div3">
<select id="combo3" name="combo3">
<option>Selecione sua opção aqui</option>
<option value='Anual 1'>Anual 1</option>
<option value='Anual 2'>Anual 2</option>
</select>
<button type="submit" id="btn3" value="btn3">Buscar</button>
</div>
</form>
To be more clear, I want that when for example the div3 appears and the person clicks the button3 doing a search, the div combobox,and the div3 and the button3 remain visible and only disappear if the person selects the div2 for example. is for my tcc if anyone can help I appreciate.
Ever tried to put
return false;
orevent.preventDefault();
on the button?– hugocsl
Joana, how would you like to put the full code here https://jsfiddle.net/ for us to help you? So it’s easier to see all the code and what you want
– Leonardo Negrão
@hugocsl I tried to put more didn’t work..
– Joana
@Leonardonegrão I don’t know how to handle this, I’m beginner kk, to learn yet
– Joana