var formatResult;

formatResult = function(data) {
    return  data.text ;
  }
  

$(document).on('change', "#using",function(e){
	 //alert("generalSearchAjaxController.php?do=fillMyList&using="+document.getElementById('using').value);
	 //$('#myList').trigger('select2');
	 $("#myList").select2({
			  placeholder: " اختر ",
			   minimumInputLength:0,//document.getElementById("searchvalue").value ,
			  multiple: false,
			  quietMillis: 100,
			  ajax: {
				url: "generalSearchAjaxController.php?do=fillMyList&using="+document.getElementById('using').value,//load myList
				dataType: 'json',
				data: function(term, page) {
					return {
						term: term, //search term
						page_limit: 10 // page size
					};  
				},
				results: function(data) {
				  return {results: data};
				  
				  //alert(data);
				}
			  },
			  formatResult: formatResult,
			  initSelection: function(element, callback) {
				var item = element.val().split(':');
				var data = {id: item[0], text: item[1]};
				callback(data);
			  }
		});
});

/*$(document).ready(function(e) {
	$("select").select2();
});*/
    $("#myList").select2({
			  placeholder: " اختر ",
			   minimumInputLength:0,//document.getElementById("searchvalue").value ,
			  multiple: false,
			  quietMillis: 100,
			  ajax: {
				url: "generalSearchAjaxController.php?do=fillMyList&using="+document.getElementById('using').value,//load myList
				dataType: 'json',
				data: function(term, page) {
					return {
						term: term, //search term
						page_limit: 10 // page size
					};  
				},
				results: function(data) {
					 //$('select.form-select').select2();
				  return {results: data};
				  //alert(data);
				}
			  },
			  formatResult: formatResult,
			  initSelection: function(element, callback) {
				var item = element.val().split(':');
				var data = {id: item[0], text: item[1]};
				callback(data);
			  }
		});



$(document).on('click', "#show_hide",function(e){
	//alert(document.getElementById('myGeneralSearch').style.display);
	if(document.getElementById('myGeneralSearch').style.display=='block')
	{
		document.getElementById('myGeneralSearch').style.display = 'none';
	}
	else if(document.getElementById('myGeneralSearch').style.display=='none')
	{
		document.getElementById('myGeneralSearch').style.display = 'block';
	}
		
	});

	
	
	
    
	
	
  