Last active
January 16, 2017 20:22
-
-
Save evercode1/5e0fb922e7bf0926c97e to your computer and use it in GitHub Desktop.
jquery for dropdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@section('scripts') | |
<script> | |
$('#category_id').on('change', function(e){ | |
var cat_id = e.target.value; | |
//ajax | |
$.get('/api/category-dropdown?cat+id=' + cat_id, function(data){ | |
//success data | |
$('#subcategory_id').empty(); | |
$('#subcategory_id').append('<option value=""> Please choose one</option>'); | |
$.each(data, function(index, subcatObj){ | |
$('#subcategory_id').append('<option value="' + subcatObj.id+'">' | |
+ subcatObj.subcategory_name + '</option>'); | |
}); | |
}); | |
}); | |
</script> | |
@endsection |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment