3 つのコンボボックス (選択) があり、最初のオプションを選択した場合に 3 番目のコンボボックスを有効にする必要があります。
- カテゴリ (有効)
- サブカテゴリ (無効)
- ぶどう (無効)
選択Wines
した場合categories
、有効にする必要がありますgrapes
$('#subcategories').attr('disabled','disabled');
$('#grapes').attr('disabled','disabled');
$("#categories").change(function () {
$("#categories option:selected").each(function () {
var v_elegido=$(this).val();
$('#subcategories').removeAttr('disabled');
if($(this).val() == "Vinos") {
$('#grapes').removeAttr('disabled');
} else {
$('#grapes').attr('disabled','disabled');
}
$.post("subcategories.php", { elegido: v_elegido }, function(data){
$("#subcategories").html(data);
});
});
<?php if ($campo == 'varietales') { ?>
<div class="col_texto" align="right"><?php echo $campo ?>: </div>
<div id="varietal" style="visibility:visible;">
<select name="varietales" id="varietales">
<option value="0">-</option>
<?php
$conn = DataBase::getInstance();
$rel=false;
$relacion='_'.$campo;
$conn->setQuery('SELECT * FROM `_'.$campo.'` ORDER BY id ASC');
if ($conn->len()==0){
$rel=true;
$relacion=$campo;
$conn->setQuery('SELECT * FROM `'.$campo.'` ORDER BY id ASC');
}
if ($conn->len()==0){
$rel=true;
$relacion=$campo.'s';
$conn->setQuery('SELECT * FROM `'.$campo.'s` ORDER BY id ASC');
}
if ($conn->len()>0){
$rs = $conn->loadObjectList();
foreach($rs as $valor){?>
<option value="<?php echo $valor->id ?>"><?php echo $valor->titulo ?></option>
<?php
}}?>
</select>
</div>
<?php } else { ?>
<?php if ($campo == 'bodegas') { ?>
<div class="col_texto" align="right" style="visibility:visible;"><?php echo $campo ?>: </div>
<div>
<select name="bodegas" id="bodegas">
<option value="0">-</option>
<?php
$conn = DataBase::getInstance();
$rel=false;
$relacion='_'.$campo;
$conn->setQuery('SELECT * FROM `_'.$campo.'` ORDER BY id ASC');
if ($conn->len()==0){
$rel=true;
$relacion=$campo;
$conn->setQuery('SELECT * FROM `'.$campo.'` ORDER BY id ASC');
}
if ($conn->len()==0){
$rel=true;
$relacion=$campo.'s';
$conn->setQuery('SELECT * FROM `'.$campo.'s` ORDER BY id ASC');
}
if ($conn->len()>0){
$rs = $conn->loadObjectList();
foreach($rs as $valor){?>
<option value="<?php echo $valor->id ?>"><?php echo $valor->titulo ?></option>
<?php
}}?>
</select>
</div>
<?php } else { ?>
<?php if ($campo == 'subcategorias') { ?>
<div class="col_texto" align="right"><?php echo $campo ?>: </div>
<div>
<select name="<?php echo $campo ?>" id="<?php echo $campo ?>">
<option value="0">-</option>
<?php
$conn = DataBase::getInstance();
$rel=false;
$relacion='_'.$campo;
$conn->setQuery('SELECT * FROM `_'.$campo.'` ORDER BY id ASC');
if ($conn->len()==0){
$rel=true;
$relacion=$campo;
$conn->setQuery('SELECT * FROM `'.$campo.'` ORDER BY id ASC');
}
if ($conn->len()==0){
$rel=true;
$relacion=$campo.'s';
$conn->setQuery('SELECT * FROM `'.$campo.'s` ORDER BY id ASC');
}
if ($conn->len()>0){
$rs = $conn->loadObjectList();
foreach($rs as $valor){?>
<option value="<?php echo $valor->id ?>"><?php echo $valor->titulo ?></option>
<?php
}}?>
</select>
</div>
<?php } else { ?>
<div class="col_texto" align="right"><?php echo $campo ?>: </div>
<div>
<select name="categorias" id="categorias">
<option value="0">-</option>
<?php
$conn = DataBase::getInstance();
$rel=false;
$relacion='_'.$campo;
$conn->setQuery('SELECT * FROM `_'.$campo.'` ORDER BY id ASC');
if ($conn->len()==0){
$rel=true;
$relacion=$campo;
$conn->setQuery('SELECT * FROM `'.$campo.'` ORDER BY id ASC');
}
if ($conn->len()==0){
$rel=true;
$relacion=$campo.'s';
$conn->setQuery('SELECT * FROM `'.$campo.'s` ORDER BY id ASC');
}
if ($conn->len()>0){
$rs = $conn->loadObjectList();
foreach($rs as $valor){?>
<option value="<?php echo $valor->id ?>"><?php echo $valor->titulo ?></option>
<?php
}}?>
</select>
</div>
<?php } ?>
<?php } ?>
<?php } ?>