// JavaScript Document
    
function loadParent()
{


    $.ajax({
           url: "db/index.php/dropdown/parentsec",
           global: false,
           type: "POST",
           async: false,
           dataType: "html",
           data: "test=1",//the name of the $_POST variable and its value
           success: function (response) //'response' is the output provided by the controller method prova()
                       {
                       //counts the number of dynamically generated options
                       var dynamic_options = $("*").index( $('.dynamic')[0] );
				
                    //removes previously dynamically generated options if they exists (not equal to 0)
                       if ( dynamic_options != (-1)) $(".dynamic").remove();
                    $("#parent_section").append(response);
                    $(".sausage").attr({selected: ' selected'});
                   }
                   
          });
    
          return false
	
}

function loadSubs()
{

	//document.getElementById("second_select").value=$("#second_select").val();

    var valore = $("#parent_section").val();
	
	
    $.ajax({
           url: "db/index.php/dropdown/getParts",
           global: false,
           type: "POST",
           async: true,
           dataType: "html",
           data: "parentsec="+valore, //the name of the $_POST variable and its value
           success:    function (response) //'response' is the output provided by the controller method prova()
                       {
                       //counts the number of dynamically generated options
                       var dynamic_options = $("*").index( $('.dynamic2')[0] );

                    //removes previously dynamically generated options if they exists (not equal to 0)
                       if ( dynamic_options != (-1)) $(".dynamic2").remove();

					   
                    $("#sub_select").append(response);
								
					
					 $(".second").attr({selected: ' selected'});
					

					
                   }
                   
          });
    
          return false
	
}
