我有 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 } ?>