public function index() { //$files = File::all(); //return view('file/create', compact('')); $paises = DB::table('clientes')->pluck("nombre","id")->all(); return view('file/create',compact('paises')); } public function selectAjax(Request $request)
public function index()
{
//$files = File::all();
//return view('file/create', compact(''));
$paises = DB::table('clientes')->pluck("nombre","id")->all();
return view('file/create',compact('paises'));
}
public function selectAjax(Request $request)
{
if($request->ajax()){
$usuario = DB::table('clientes')->where('pais',$request->pais)->pluck("nombre","id")->all();
$data = view('file',compact('usuario'))->render();
return response()->json(['options'=>$data]);
}
}
@if(!empty($usuario))
@foreach($usuario as $value)
<option>--- Select State ---</option>
@if(!empty($usuario))
@foreach($usuario as $value)
<option value="{{ $usuario }}">{{ $usuario }}</option>
@endforeach
@endif
<script type="text/javascript">
$("select[nombre='pais']").change(function(){
var id_country = $(this).val();
// var token = $("input[name='_token']").val();
$.ajax({
url: "<?php echo route('file') ?>",
method: 'POST',
data: {id_country:pais},
success: function(data) {
$("select[nombre='pais'").html('');
$("select[nombre='pais'").html(data.options);
}
});
});
</script>
@endforeach
@endif
$("select[nombre='pais']").change(function(){var id_country = $(this).val();// var token = $("input[name='_token']").val();$.ajax({url: "",method: 'POST',data:{id_country:pais},success: function(data){$("select[nombre='pais'").html('');$("select[nombre='pais'").html(data.options);}});});