I am trying to display some information in a bootstrap modal based on some values.
Here is the work flow
1.Display Hyperlinks in a loop with a title.
2.W
Assuming your foreach
outputs links like this:
title
another title
You could then invoke the click
method instead of show.bs.modal
in order to use $(this)
.
So your code will change to:
$('.btn-block').on('click',function(){
var id = $(this).data('id');
alert(id);
$('.modal-body').html('loading');
$.ajax({
type: 'POST',
url: '../Functions/form_process.php?action=getdetailsbyid',
data:{id: id},
success: function(data) {
$('.modal-body').html(data);
},
error:function(err){
alert("error"+JSON.stringify(err));
}
});
});
Here is an Example
Otherwise you will need to use a unique id on all your outputted links (which you can do using a counter in your foreach
)