I am created the pop up model when I am clicked the Edit Meeting File
button in the table, my problem is how to grab the file name of the position of an existing row when I have selected?
下面是我的编码:
<?php
$i = 1;
$files = scandir("upload_dms_file/uploads_filing_file");
$date = $files[$a];
for ($a = 2; $a < count($files); $a++) {
?>
<tr>
<td> <?php echo $i++; ?></td>
<td> <a href="upload_dms_file/uploads_filing_file/<?php echo $files[$a]; ?>" target="_blank"> <?php echo $files[$a]; ?></a></td>
<td>
<button class="btn btn-sm btn-primary"><a href="upload_dms_file/uploads_filing_file/<?php echo $files[$a]; ?>"
download="<?php echo $files[$a]; ?>" style="color: white;">
Download</a></button>
   
<button class="btn btn-sm btn-primary"><a
href="upload_dms_file/delete_filing_storage.php?name=uploads_filing_file/<?php echo $files[$a]; ?>" style="color: white;">
Delete
</a></button>
<?php
if ($files[$a][0] == 'm') {
?>
<button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#myModal">Edit Meeting File</button>
<?php
}
?>
弹出模态框内容编码:
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
Current Filing File:
<input value="hi"></input>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Below is my output, for example in this ouput, I am click the No 3 Edit Meeting File
button, then any one can guide me how to show No 3 Filing File
name in the popup model box input. If I have clicked No 4 button, then will show No 4 Filing File
name in the popup model box input:
The text you're trying to target is in the previous
td
to thebutton
which is clicked. As such put a unique class on that button to make targeting it easier, then traverse the DOM to get thetext()
within thetd
: