I'm currently building a file download in PHP like Google Drive but just a way more simple. So in my case I have a list with some files. To get rid of a download button in each row, I planned using a single download button and jQuerys seleactable function:
$( "#storage-files-table" ).selectable();
Now I can select single or multiple rows. When I press my download button now, I want to get a list of all selected elements so that I now which file should be served for download. Does anyone know how I can get this done?
jQuery(document).ready(function($) {
$("table").selectable();
});
function download() {
//Here I want to get a list of all selected rows
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button onclick="download()">Download</button>
<table>
<thead>
<th>col1</th>
<th>col2</th>
<th>col3</th>
</thead>
<tbody>
<tr>
<td>a1</td>
<td>a2</td>
<td>a3</td>
</tr>
<tr>
<td>b1</td>
<td>b2</td>
<td>b3</td>
</tr>
<tr>
<td>c1</td>
<td>c2</td>
<td>c3</td>
</tr>
</tbody>
</table>
.ui-selected, which is mentioned in the first answer in the link above, and also shown in the answer someone has posted below.