I want to try for dependent dropdown in laravel 5. In which main dropdown having several lists like(Electronics,Automobiles) and from one of them click or change event. I want to create another whole dropdown . if I clicked on Electronics than one another dropdown will be Automatic generated for electronics.
here's code:
<script>
$("#category").on('change', function(e){
alert("test");
console.log(e);
var category_id = e.target.value;
var s = $('<select />');
//ajax
$.get('/index?category_id=' + category_id, function(data){
for(var val in data) {
$('<option />', {value: val, text: data[val]}).appendTo(s);
alert(val);
s.appendTo('body');} // or wherever it should be
});
});
</script>
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2ayhoL7
via IFTTT
Aucun commentaire:
Enregistrer un commentaire