I would like to pass an row ID from one section of the page to another in the following way:
The user will click on the trash can and a delete confirmation message will come up. The following code shows how I retrieve the list from the database:
<?php while($row = mysql_fetch_array($query_set)) { ?>
<tr>
<td><?php echo $row['cover_name'] ?></td>
<td><?php echo 'R '.$row['sum_insured'] ?></td>
<td><?php echo $row['info'] ?></td>
<td>
<a href="cover-type.php?id=<?php echo $row['coverid']?>"><i class="fa fa-pencil"></i></a>
<a href="#myModal" onclick="<?php $coverid = $row['coverid'] ?>" role="button" data-toggle="modal"><i class="fa fa-trash-o"></i></a><!-- This is the link for the trash can to pass the id -->
</td>
</tr>
<?php } ?>
After clicking on the following <a href="#myModal" onclick="<?php $coverid = $row['coverid'] ?>" role="button" data-toggle="modal"><i class="fa fa-trash-o"></i></a><!-- This is the link for the trash can to pass the id -->
The following pop will come up:
and it has the following code:
<div class="modal small fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Delete Confirmation</h3>
</div>
<div class="modal-body">
<p class="error-text"><i class="fa fa-warning modal-icon"></i>Are you sure you want to delete the cover?<br>This cannot be undone.</p>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>
<a href="delete-cover.php?id=<?php echo $coverid ?>" class="btn btn-danger" >Delete</a><!-- I would like to pass the id from that trash can button this the delete button -->
</div>
</div>
</div>
</div>
I would like to pass the id from the trash can link to the delete button that pops up. Any assistance will be appreciated
This is surely not good:
onclick="<?php $coverid = $row['coverid'] ?>"
It should be somethig like that:
onclick="jsfunctionname(<?php echo $row['coverid'];?>);"
Or if you use jQuery on selector, then add a data-id="<?php echo $row['coverid'];?>"
to the link, and get like $(this).data('id');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.