i'm trying to crop multiple images using jcrop plugin. this plugin is working for single image crop but i have no idea how to crop multiple images individually from loop. my php file is as follows
<?php
$id=$_GET['id'];
$query_image=mysql_query("SELECT * FROM tbl_images WHERE `id`='$id'");
$j=0;
while($rowq=mysql_fetch_assoc($query_image))
{
$image_source = $rowq['image'];
?>
<div>
<img src="../image_files/<?php echo $image_source;?>" width="550px" id="cropbox_<?php echo $j;?>" />
<form action="crop_image.php?id=<?php echo $id;?>" method="post" onsubmit="return checkCoords()">
<input type="text" id="x" name="x" value="" />
<input type="text" id="y" name="y" value=""/>
<input type="text" id="w" name="w" value=""/>
<input type="text" id="h" name="h" value=""/>
<input type="submit" value="crop">
<input type="reset" value="cancel">
</form>
</div>
<?php
$j++;
}
$count = $j;
?>
and jcrop functions are as follows
<script type="text/javascript">
var i;
var count = "<?php echo $count;?>";
$(function(){
for(i=0; i<count;i++)
{
$('#cropbox_'+i).Jcrop({
aspectRatio: 0,
onSelect: updateCoords
});
}
});
function updateCoords(c)
{
var x = $('#x').val(c.x);
var y = $('#y').val(c.y);
$('#w').val(c.w);
$('#h').val(c.h);
};
function checkCoords(k)
{
if (parseInt($('#w_'+k).val())) return true;
alert('Please select a crop region then press submit.');
return false;
};
</script>
but the function updateCoords(c) not returning co-ordinate values. if you have any suggestions on this code then please help me. thank you in advance.
for image form
for updateCoords(c) function
hi sujan try this