1
I would like, for example, when choosing the option '10 people' in the select 'Size', I could hide specific options in the selects 'Model', 'Fillings', 'Options to Drain' and 'Decoration'.
Example:
<div class="form-group">
<span class="resume-subtitle">Escolha o tamanho</span>
<select id="tamanho" name="tamanho" class="form-control select2-list select-options-1" data-placeholder="Clique aqui para escolher" multiple>
<optgroup label="Tamanho">
<?php
$strTamanho = "SELECT * FROM bolo_mesa_itens WHERE tipo='tamanho'";
$rsTamanho = mysql_query($strTamanho);
while($rowTamanho = mysql_fetch_array($rsTamanho)) {
echo '<option value="' . $rowTamanho['value'] . '">' . $rowTamanho['nome'] . '</option>';
}
?>
</optgroup>
</select>
</div>
<div class="form-group">
<span class="resume-subtitle">Escolha o modelo</span>
<select id="modelo" name="modelo" class="form-control select2-list select-options-1" data-placeholder="Clique aqui para escolher" multiple>
<optgroup label="Tipo de Bolo">
<?php
$strModelo = "SELECT * FROM bolo_mesa_itens WHERE tipo='modelo'";
$rsModelo = mysql_query($strModelo);
while($rowModelo = mysql_fetch_array($rsModelo)) {
echo '<option class="10_pessoas" value="' . $rowModelo['value'] . '">' . $rowModelo['nome'] . '</option>';
}
?>
</select>
</div>
It’s an excellent output, associating filtering to classes! But if my value is a common string like the one displayed, like "10 People"?
– Murilo Ravani
@Muriloravani has no problem. There you have to change the model class to the value that references the size.
– viana
Sorry @Ack, I don’t understand... is that in case, I can’t have a class with spaces like . 10 People (I didn’t quote there, but my value of this field is like this instead of 10_people. You can exemplify for me?
– Murilo Ravani
Buddy, I just finished testing the environment, and your code makes the filter right. When I adapt to mine ends up not doing... is it because I’m using the plugin Select2? I updated the post code to match mine. As a test, I also forced all the 'model' options to stay with the '10_people' class (which is the value that comes now from the database instead of 10 People).
– Murilo Ravani
@Muriloravani Cara answering the first question there, good even being separate value in class, works here for me. Now your adaptation, there’s no way I can play it. Did you insert jQuery correctly? Without it it won’t even work.
– viana
@Muriloravani I will analyze here to see if there are any mistakes.
– viana
I can give you access to see online too if you want :)
– Murilo Ravani
Let’s go continue this discussion in chat.
– viana