I have a table that looks like this
Name Occupation Detail
abc student details
i want to set a bootstrap modal link on details column, which not only works as a model but also picks the id of that specific row.
At present i am working with this code
echo "<td><a href='#myModal'?id=".$row['id']."\" data-toggle='modal' data-target='#myModal '>Details</a></td>";
Modal is working properly but i am not able to use id of the row properly with the modal Would appreciate if someone could help me
http://jsfiddle.net/0u19axax/1/
You can use show.bs.modal
event to extract data from your a
.
$('#myModal').on('show.bs.modal', function(e){
console.log($(e.relatedTarget).attr('data-id'))
})
I moved the id to data-id
because it did not work with the id in href
<a href='#myModal' data-id='.$row['id'].' data-toggle='modal' data-target='#myModal '>Details</a>
Sorry, I don't know PHP so I'm not sure it'll work PHP wise.
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.