Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. // There are two ways...
  2. // No:1.......
  3.  
  4. $(function() {
  5. $('#category').change(function() {
  6. var cat = $(this).val();
  7. $.get('{{ url("categories") }}', {'cat_id': cat}, function (data) {
  8. $('#subcategory').empty();
  9.  
  10. $.each(data, function(key, value) {
  11. $('#subcategory').append("<option value='"+ value.id +"'>" + value.name + "</option>");
  12. });
  13. });
  14. });
  15. });
  16.  
  17.  
  18. // No:2............
  19.  
  20. $('#upozilla').prepend('<option value="1" selected>--None--</option>');
  21. $('#district').on('change', function(e){ // Pre-populate upozilla with selecting district dropdown
  22. console.log(e);
  23. var district_id = e.target.value;
  24. $('#upozilla').empty();
  25. $.get('{{ url("/upozilla-populate?district_id=") }}'+district_id, function(data){
  26. $.each(data, function(index, upozillaObj){
  27. $("#upozilla").empty();
  28. $('#upozilla').append('<option value="'+upozillaObj.id+'">'+upozillaObj.upozilla_name_bn+'</option>');
  29. });
  30. $('#upozilla').prepend('<option value="1" selected>--None--</option>');
  31. });
  32. });
  33.  
  34. // Then get the cat_id or district_id in php file and select data and return the data in json format
  35. // In laravel get the id in your controller and return the data in json format
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement