I have a list of items on the webpage and to the right I have Edit buttons.
echo '<a href="#myModal?id='.$row['id'].'" data-toggle="modal" >';
How do I properly pass parameter trough <a>
tag to the bootstrap modal? My code above doesn't work with ?id='.row['id']'
part. I'm getting the Error: Syntax error, unrecognized expression: #myModal?id=12. But <a href="#myModal data-toggle="modal">Edit</a>
opens bootstrap modal.
Thank you
You are not passing the value through this..
href="#myModal?id='.$row['id'].'"
because this is the modals name..
You can do this only by ajax request. You must populate the modal using ajax function.
Take the click event of a tag
Eg:
<a href="JavaScript:void(0);" class="aTagclass" data-id="1">open modal</a>
$('.aTagclass').click(function(){
// you can take data-id by
Var id= $(this).data('id');
// call your ajax function using the id
//populate modal
// open modal here
});
Note: above code may have errors.