vandan's avatar
Level 13

replace select2 to input text dynamic

hii i have dropdown like client/sales/location and anthor dropdown is dependent to previous one like when i select client then other dropdown fetch value to client level table when i select sales then fetch value to other dropdown in sales table

in case of when i select client then i have only one value so when i select client level then remove other dropdown and add input box to replace select2 dropdown how it possible?

here is my code

$(document).ready(function(){
	$('.location-select-class').multiSelect();
	$(document).on('change','.alert-select-class',function(){
		var eid = $(this).attr('id');
		var splitData = eid.split("-");
		let alertLevel = $(this).val();
		if(alertLevel != 'client')
		{
			$.ajax({
				type:'POST',
				data:{'_token':'{{csrf_token()}}','alertLevel': alertLevel,'clientId':'{{$client->id}}'},
				url:"{{route('findclientsalescenter')}}",
				success:function(response){
					$("#emaillocation-"+splitData[1]).empty();
					$.each(response.data, function(key,value){
						$("#emaillocation-"+splitData[1]).append('<option value='+ value.id +'>'+ value.name +'</option>').trigger('change');
						$("#emaillocation-"+splitData[1]).multiSelect('refresh'); 
					});
				}
			});
		}
		else
		{
			$("#emaillocation-"+splitData[1]).empty();
			$("#emaillocation-"+splitData[1]).append('<option value="{{$client->id}}"> {{$client->name}} </option>').prop("selected","selected").trigger('change');
			$("#emaillocation-"+splitData[1]).multiSelect('refresh'); 
		}
	});
});

i want input box in else condtion so replace select and add input in else condition how to do it

0 likes
0 replies

Please or to participate in this conversation.