php - how to send hidden details when click on image in while loop -


this code

while ($row = $result->fetch_assoc()) { $imgpath=$row['image_name']; $id=$row['id']; <input type="hidden" name="id" value="' . $row['id'] . '" > 

here when click send id next page

<img src="'.$imgpath.'" height="170" width="600" title="album-name" class="img-responsive" alt=" " /> } 

can use form it?

jquery ajax job. need attach event handler function click event image. don'it need hidden element, attach $row['id'] id attribute of <img> element, on click, post via ajax.

try :

//first, make id attribute of <img> equal $id($row['id']) <img src="'.$imgpath.'" id="$id" height="170" width="600" title="album-name" class="img-responsive" alt=" " /> 

then, add event handler :

$('body').on('click','img',function(){   var id = $(this).attr('id');// id   $.post( "target.php", {id : id}, function( data ) {//post id target page      //do whatever..   }); }); 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -