我在單個頁面上有3個下拉菜單, 情景是當3個下拉值中的任何一個變化時,剩餘的值需要設置爲默認值。 我如何實現這一目標?任何幫助將不勝感激。電流變化時更改其他下拉值
{
jQuery('select').on('change', function() {
jsonObj = [];
var id = (this.value);
var fullImgUrl = jQuery('#'+id).val();
item = {}
item['pcCase'] = id;
jsonObj.push(item);
if(id !== '0')
{
jQuery("#img-div").css("opacity","1");
jQuery("#prd-select-img").attr("src",fullImgUrl);
}
else
{
jQuery("#img-div").css("opacity","0");
}
jsonString = JSON.stringify(jsonObj);
jQuery("#continue").click(function(){
jQuery.ajax({
type:'POST',
url:'<?php echo $baseUrl; ?>getContent.php',
data:{id:id},
success:function(msg){
if(msg){
alert('success');
}
}
});
});
});
}
<div class="head-custome-pc">
<div class="container">
<h1 class="text-center">Customize Your PC</h1>
<div class="steptitle">
<h2 class="text-center"><ins>Step 1 : Choose Your Pc Case</ins></h2>
</div>
<div class="col-md-6 col-sm-5 col-xs-12">
<div class="steps">
<p> > Step 1:Choose Your PC Case</p>
<p> > Step 2:Choose Your Motherboard and Processor</p>
<p> > Step 3:Choose Your Graphics Card and Power Supply</p>
<p> > Step 4:Choose Your RAM</p>
<p> > Step 5:Choose Your HDD/SSD</p>
<p> > Step 6:Choose Your Accessories</p>
<p> > Step 7:Submit</p>
</div>
</div>
<div id="change-part" class="col-md-3 col-sm-3 col-xs-12">
<form>
<div class="form-group">
<label for="sel1">ITX - Small</label>
<select class="form-control" id="sel1">
<option value="0">--Choose--</option>
<?php
$_products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('customized_product', '1')
->addAttributeToFilter('itx_small', '1')
->load();
foreach($_products as $product)
{
?>
<option value="<?php echo $product->getId(); ?>"><?php echo $product->getName()." ".", S$".$product->getPrice(); ?></option>
<?php }
foreach($_products as $product)
{
?>
<input type="hidden" id= "<?php echo $product->getId(); ?>" value="<?php echo $product->getImageUrl(); ?>" />
<?php } ?>
</select>
</div>
<p class="text-center or">OR</p>
<div class="form-group">
<label for="sel1">mATX - Medium</label>
<select class="form-control" id="sel2">
<option value="0">--Choose--</option>
<?php
$_products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('customized_product', '1')
->addAttributeToFilter('m_atx_medium', '1')
->load();
foreach($_products as $product)
{
?>
<option value="<?php echo $product->getId(); ?>"><?php echo $product->getName()." ".", S$".$product->getPrice(); ?></option>
<?php }
foreach($_products as $product)
{
?>
<input type="hidden" id= "<?php echo $product->getId(); ?>" value="<?php echo $product->getImageUrl(); ?>" />
<?php } ?>
</select>
</div>
<p class="text-center or">OR</p>
<div class="form-group">
<label for="sel1">ATX - Large</label>
<select class="form-control" id="sel3">
<option value="0">--Choose--</option>
<?php
$_products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('customized_product', '1')
->addAttributeToFilter('atx_large', '1')
->load();
foreach($_products as $product)
{
?>
<option value="<?php echo $product->getId(); ?>"><?php echo $product->getName()." ".", S$".$product->getPrice(); ?></option>
<?php }
foreach($_products as $product)
{
?>
<input type="hidden" id="<?php echo $product->getId(); ?>" value="<?php echo $product->getImageUrl(); ?>" />
<?php } ?>
</select>
</div>
</form>
</div>
<div class="col-md-3 col-sm-4 col-xs-12" id="img-div">
<img id="prd-select-img" src="" class="img-responsive center-block">
</div>
<div class="col-md-6 col-md-offset-6 col-xs-12">
<div class="next-butns">
<button class="btn-save">SAVE</button> <button id="continue" class="btn-continue">continue</button>
</div>
</div>
</div>
分享你的代碼,瞭解代碼和問題。 –
請花些時間,提供你的html和js,你到目前爲止有什麼。 –
是的,它可以完成。請分享您的code.it將更好地瞭解 –