I want to convert my data on javascript to a php value, and my code on script is like this:
<script type="text/javascript">
$(document).on("click", ".open-image", function (e) {
e.preventDefault();
var _self = $(this);
var image = _self.data('img');
$("#img").val(image);
$("#img").attr('src',image);
$(_self.attr('href')).modal('show');
});
</script>
as you can see, the data there is the img which i am displaying on the modal, and this is the code:
<div class="modal fade" id="openimage" 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>
<h4 class="modal-title"><i class="fa fa-envelope-o"></i> View Image</h4>
</div>
<form action="#" method="post">
<div class="modal-body">
<center><td width="50" align="center"><img align="center" src="img" id="img" value="img" class="img-rounded" width="200" height="200"></td>
</div>
<div class="modal-footer clearfix">
<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-times"></i> Discard</button>
<button type="submit" class="btn btn-primary pull-left"><i class="fa fa-envelope"></i> Send Message</button>
</div>
</form>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
what i want to do is to convert the img to a php value so I want to echo it, as you can see on the modal, i coded it like this:
<img align="center" src="img" id="img" value="img" class="img-rounded" width="200" height="200">
and I want to convert it to php value like $img and make it like this:
<img align="center" src="<?php echo $img; ?>" id="img" value="img" class="img-rounded" width="200" height="200">
how should i do it? hope u understand.