set options using jquery in laravel form collective
//...
{!! Form::select('jobsList[]', [], null, ['id' => 'job', 'class' => 'form-control' 'multiple', 'style' => 'width: 60%; margin-top: 10px;', 'disabled'=>'disabled']) !!}
..//<script>
$(document).ready(function() {
//Make an Ajax request to a Laravel route
//This will return the data that we can add to our Select element.
$.ajax({
url: 'YOUR URL GOES HERE',
type: 'get',
success: function(data){
//Log the data to the console so that
//you can get a better view of what the script is returning.
console.log(data);
$.each(data, function(key, value){
//Use the Option() constructor to create a new HTMLOptionElement.
var option = new Option(key, value);
//Convert the HTMLOptionElement into a JQuery object that can be used with the append method.
$(option).html(value);
//Append the option to our Select element.
$("#job").append(option);
});
}
});
});
</script>
Also in JavaScript:
- full screen a div
- enable swipe using javascript
- camelcase to hyphenated javascript
- change the color of toast toastr js
- how to add objects in array in javascript
- focus on input field vuejs event
- return last two values of array in javascript
- Ajax send date to MVC
- datatable after. draw
- js string have number js
- javascript array stackoverflow
- json in listview flutter
- do more than one thing at start of or loop javascript
- javascript get object where
- $.notify is not a function angular
- javascript two character integer
- send data from form to another page angular
- access to xmlhttprequest at angular 8
- js remove the last character of a string
- site:stackoverflow.com javascript replace multiple spaces with single space
- how to use redirect in react
- Angular 9 tutorial
- threejs
- save or update mongoose