Hi, all i have a problem with my code i build 3 dynamic drop downs in which values comes from database.when someone select a value from first drop down 2nd shows related values in it and when someone select value from 2nd drop down third shows related values.
in my case i have three categories in 2 categories all these 3 drop downs are used and in thired category only 2 are used. in edit page where all values shows from database i tried to get values in drop down 2 drop down that are used in all 3 categories work well but when i tried to get the value of thired drop down it affects third category and hides all drop down values.
Here is my code for first two categories using ajax jquery with php
What I have tried:
var cid = <?php echo $cid = intval($_GET['cid']) ?>;
if(cid == 1 || cid == 2)
{
var brand_id = <?php echo $db_brand ?>;
if(brand_id == <?php echo $db_brand ?>)
{
$.post("getbrandlist.php",{category:cid,brandid:brand_id}, function(brandlist){
$("#brand").html(brandlist);
var plateform_id = <?php echo $db_plateform ?>;
var model = <?php echo $db_model ?>;
if(plateform_id == <?php echo $db_plateform ?> || model == <?php echo $db_model ?>)
{
$.post("getplateformlist.php",{brandid: brand_id,plateform: plateform_id},function(plateformlist){
$("#plateform").html(plateformlist);
});
$("#brand").change(function(){
var brand = $(this).val();
if(brand)
{
$.post("getplateformlist.php",{brandid: brand},function(plist){
$("#plateform").html(plist);
$("#plateform").change(function(){
var plateformid = $(this).val();
if(plateformid)
{
$.post("getmodellist.php",{plateform: plateformid},function(mlist){
$("#modellist").html(mlist);
});
}
});
});
}
});
}
});
}
}
and for third category where unknown problem occurs code here
var brand_id = <?php echo $db_brand ?>;
if(brand_id == <?php echo $db_brand ?>)
{
$.post("getbrandlist.php",{category:cid,brandid:brand_id}, function(brandlist){
$("#brand").html(brandlist);
var plateform_id = <?php echo $db_plateform ?>;
if(plateform_id == <?php echo $db_plateform ?>)
{
$.post("getplateformlist.php",{brandid: brand_id,plateform: plateform_id},function(plateformlist){
$("#plateform").html(plateformlist);
});
$("#brand").change(function(){
var brand = $(this).val();
if(brand)
{
$.post("getplateformlist.php",{brandid: brand},function(plist){
$("#plateform").html(plist);
});
}
});
}
});
}