Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <div class="form-group">
  2. {!! Form::label('departa', 'Departamento:', ['class' => 'col-lg-2 control-label']) !!}
  3. <div class="col-lg-10">
  4. {!! Form::select('departamento',$departamento_honduras,null,['placeholder'=>'Selecciona','id'=>'departamento_dinamico']) !!}
  5. </div>
  6. </div>
  7. <br>
  8. <br>
  9.  
  10. <div class="form-group">
  11. {!! Form::label('munic', 'Municipio:', ['class' => 'col-lg-2 control-label']) !!}
  12. <div class="col-lg-10">
  13. {!! Form::select('municipios',['placeholder'=>'Selecciona'],null,['id'=>'municipio_dinamico']) !!}
  14. </div>
  15. </div>
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23. $("#departamento").change(function (event) {
  24. $.get("municipios_dinamico/"+event.target.value+"",function (response,id_departamento) {
  25.  
  26. console.log(response);
  27. // $("#unidades").empty();
  28. $("#municipio").empty();
  29. for (i=0;i<response.length;i++){
  30. $("#municipio").append("<option value='"+response[i].id+"'>"+response[i].nombre+"</option>");
  31. }
  32. });
  33. });
  34.  
  35. Route::get('municipios_dinamico/{id}',[
  36. 'as'=>'municipios_dinamico',
  37. 'uses'=>'icf@municipio_dinamico_get'
  38. ]);
  39.  
  40. public static function municipio_dinamico_get(Request $request,$id)
  41. {
  42. if ($request->ajax()){
  43. $municipios=municipios::municipios_dinamico($id);
  44. return response()->json($municipios);
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement