function abilita_select(obj,target){

if ($('select#'+obj).val()=='') {
    $('select#'+target).attr('disabled',true);            
}
else {
    $('select#'+target).attr('disabled',false); 
}        

}


function disabilita_select(target){
    $('select#'+target).attr('disabled',true).val('');                
}

 
  $(document).ready(function() {    
            
    //RICHIESTA AJAX SE SELEZIONO MARCA
    $('#marca').change(function(e){
    if($('#marca').val() != "")
    {
        $.ajax({
            url: 'select_dsp.php',
            type: 'POST',
            data: "val="+$('#marca').val(),
               dataType: 'text',
            timeout: 1000,
            error: function(){
                alert('Error loading XML document');
            },
               success: function(text){
                   $('#modello').html('<option value="">[--indifferente--]</option>');
                   $('#modello').append(text)
            }
        });
    }
    else{
        $('#modello').html('<option value="">[--indifferente--]</option>');
    }
    });
  

 });
  

 
  function get_selected(id,marca,modello){
    
        $.ajax({
            url: 'select_dsp.php',
            type: 'GET',
            data: "id="+id+"&marca="+marca+"&modello="+modello,
               dataType: 'text',
            timeout: 1000,
            error: function(){
                alert('Errore nel caricamento dei dati');
            },
               success: function(text){
                   $("#"+id).html('<option value="">[--indifferente--]</option>');
                   $("#"+id).append(text)
            }
        });

 } 

