I have displayed a listing in laravel from table given as below:
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th></th>
</tr>
</thead>
<tbody>
@php $sln = 1 @endphp
@foreach ($roles as $role)
<tr>
<td>{{ $sln++ }}</td>
<td>{{ $role->name }}</td>
<td><a href="" class="btn addbtn editrole" data-bs-toggle="modal" data-bs-target="#role-edit-modal">Edit</a></td>
</tr>
@endforeach
</tbody>
</table>
I have also a modal form in bootstrap on clicking on the <a> Edit which is given below.
<div class="modal fade" id="role-edit-modal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Edit Role</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="formbox">
<form action="" method="post" id="role-form">
<div class="form-group">
<label for="roleName">Role Name</label>
<input type="text" name="name" id="role-name" class="form-control" maxlength="50" value="{{ old('email', $role->name) }}">
<span id="role-error" class="text-danger"></span>
</div>
<div class="btngroup">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
I wanted to pass the value of $role->id from to this modal file and display the value in$role->name`
How do I passw the value of id on clicking the edit button in jQuery and trigger the modal window.