42438

show data in lightbox

<img src="https://i.stack.imgur.com/Wy9ab.jpg" alt="enter image description here">

i want to show related data on click red circled image in light box but when i click it always shows the data in light box of the first record in the table i want to show concern record of click ,my code is here in JavaScript i have write these lines of code

<script> function manageLightbox(visibility,id) { document.getElementById('overlay').style.display = visibility; document.getElementById('content').style.display = visibility; } </script>

i have called this function in my html

<a href="#"><img src="images/core/icon16/zoom.png" title="View" onClick="return manageLightbox('block','<?php echo $res['id']?>');" /></a>

the html of my light box is just here

<div id="content" class="content"> <a href = "javascript:void(0)" onClick="return manageLightbox('none')"> <img src="images/images1.jpeg" style="width:25px; height:25px; float:right"/></a> <br/> <center> <table> <tr> <td>Product_ID</td> <td><input type="text" name="product_id" value="<?php echo $row['id']; ?>"/></td> </tr> <tr> <td>Name</td> <td><input type="text" name="name" value="<?php echo $row['name']; ?>"/></td> </tr> //and all other fields in light box .... </table> </center> </div> <div id="overlay" class="overlay" onClick="return manageLightbox("")></div>

Answer1:

First, you are using $res in your call, and $row in your view, maybe wrong name? Second, do you use AJAX? With Jquery you can make easy AJAX calls and put the data into a place where you want. So: Use the $res["id"] as data to the data you want, (return for example the table) and include that in your div content.

The reason why you see only the first is because you assign multiple div's with the same name, javascript will return the first element with the given name. By using AJAX you can make a call, and the information will be included in the only div "content" which you have on your view.

Example:

<script> $(".link_zoom").click(function(){ //add class to a href: class='link_zoom', when click, trigger event $.ajax({ type: 'POST' url: "someaction.do.php", data: "id=" + $(this).attr("id"), //add to the a href: id='<?php echo $res["id"]; ?>' dataType: "html", success: function(html) { $(".content").html(html); //will add the html to the content div } }); }); </script>

Recommend

  • Line with fill and stroke
  • Youtube Video Player Fullscreen click event
  • Change the width of the JQM panels
  • Is it better to use the “hidden” CSS attribute or fetch each set of new images?
  • Making Google Visualization - Annotation Chart to work in GWT
  • Python PIL to extract number from image
  • Outputting SharePoint Hyperlink Column as URL
  • Update Google Maps traffic layer without page reloading
  • Disable Kendo Autocomplete
  • Simulate click Geckofx vb,net
  • How to view images from protected folder with php?
  • Button click event not firing in jQuery
  • Moving Android View and preventing onDraw to be called over and over again
  • Chart.js Multiple dataset
  • How do I get HTML corresponding to current DOM tree?
  • Display images in Django
  • HTTP/2 streams vs HTTP/1.1 connections
  • Custom Tabgroup Appcelerator
  • How do I pass the string value parameter of the selected list item from an auto-populated dropdown l
  • JQuery Internet Explorer and ajaxstop
  • JSON response opens as a file, but I can't access it with JavaScript
  • Jquery UI tool tip close icon
  • Syntax for setting draggablecursor property in google maps api
  • Align navbar back button on right side
  • HTML download movie download link
  • DotNetZip - Calculate final zip size before calling Save(stream)
  • Resize panoramic image to fixed size
  • Change an a tag attribute in JavaScript based on screen width
  • Importing jscolor library in angular 2
  • Why winpcap requires both .lib and .dll to run?
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • GridView Sorting works once only
  • How to get icons for entities from eclipse?
  • Proper way to use connect-multiparty with express.js?
  • Load html files in TinyMce
  • Free memory of cv::Mat loaded using FileStorage API
  • How to set the response of a form post action to a iframe source?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • unknown Exception android
  • JaxB to read class hierarchy