I want to ask that how can I call a value from javascript to html blade in laravel.
Here is my JavaScript code:
<script type="text/javascript">
function valueFunction(){
var output = document.getElementById('teacherId').value;
console.log(output);
document.getElementById('output').innerHTML = output;
}
</script>
Here is my Laravel Html:
<select id="teacherId" onchange="valueFunction()">
<option>Select Teacher</option>
@foreach($users as $user)
<option value="{{$user->id}}">{{$user->name}}</option>
@endforeach
</select>
{{$users[]->name}}
<output id="output"></output>
Controller Code:
$users = User::all();
$students = Students::all();
return view('admin.assignStudent', compact('users','students'));
As I am getting the value in output tag, but I want to call the value of javascrpt in {{$users[output]->name}} here.
Thank you.