Hi I\'m passing php variable to twitter boostrap modal. but I cant get the right id when I click the link inside the modal. please see code below. first I have created a fo
I have made quite some edits to your code, let's start with what you were doing first:
".$nattco['address']."
";
This has to be instead of .
You only need one modal box. We will pass the id for them through jQuery. So create only 1 static modal box at the end of your table.
Now the things you need to do:
1) Make use of this 2) Give a class for your buttons in the modal box: 3) Add And finally, the jQuery bit: That's all. This minimizes your code so that modal box is not repeated while dynamically passing You can have a look a the demo here: DEMO $id = $nattco['id']; as your so it will be:
$id = $nattco['id'];
echo " #...rest of your code
Edit
Owner
FLA
Delete
href and class to your` tag :`".$nattco['agent_name']." `
$('a.modal-box').click(function(e){
id=$(this).closest('tr').attr('id');
$('.modal-body .edit').attr('href','update_sub_agent.php?id='+id+'');
$('.modal-body .owner').attr('href','owner.php.php?id='+id+'');
$('.modal-body .fla').attr('href','fla.php?id='+id+'');
$('.modal-body .delete').attr('href','delete.php?id='+id+'');
});
id of the clicked row.