Results 1 to 5 of 5

Thread: how to display image in html table uisng jquery

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Location
    Karachi
    Posts
    551

    how to display image in html table uisng jquery

    i have following line of code along with gif image ..it showing all database driven data but not image

    any help

    Code:
     for (var i = 0; i < data.d.length; i++) {
     
     $("#tbl").append("<tr  bgcolor= lightblue><td>" + (data.d[i].CustomerID) + "</td><td>" + (data.d[i].CompanyName) + "</td>" + "<td> <img  src=" +  "'" + "detail.gif" +"'" + "height=20 width=20>  </td>" +  "</tr>");
    Last edited by ERUM; Apr 27th, 2013 at 11:28 PM. Reason: spelling mistake
    There is no achievement without goals

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Location
    Karachi
    Posts
    551

    Re: how to display image in html table uisng jquery

    solved using this

    for (var i = 0; i < data.d.length; i++) {

    $("#tbl").append("<tr bgcolor= lightblue><td>" + (data.d[i].CustomerID) + "</td><td>" + (data.d[i].CompanyName) + "</td>" + "<td> <img src=" + "'" + "detail.gif" +"'" + "height=50 width=50> </td>" + "</tr>");
    There is no achievement without goals

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Location
    Karachi
    Posts
    551

    Re: how to display image in html table uisng jquery

    I WANT TO open div when href is clicked in loop

    Code:
      for (var i = 0; i < data.d.length; i++) {
     
    // var newRow =  $("#tbl").append("<tr  bgcolor= lightblue><td>" + (data.d[i].CustomerID) + "</td><td>" + (data.d[i].CompanyName) + "</td>" + "<td> <img   src=" +  "'" + "detail.gif" +"'" +  "id=" + "'" +"imgSmile" +"'" + "height=50 width=50>  </td>" +  "</tr>");
    var newRow =  $("#tbl").append("<tr  bgcolor= lightblue><td>" + (data.d[i].CustomerID) + "</td><td>" + (data.d[i].CompanyName) + "</td>" + "<td><a href=#> <img   src=" +  "'" + "detail.gif" +"'" +  "id=" + "'" +"imgSmile" +"'" + "height=50 width=50></a>  </td>" +  "</tr>");
    how to do this ..i.e for each row I need to open div whne image is clicked ????????????????????
    There is no achievement without goals

  4. #4
    Member
    Join Date
    Jul 2019
    Location
    Ahmedabad
    Posts
    57

    Re: how to display image in html table uisng jquery

    Try this query
    Code:
    function(response) {
            var trHTML = '';
            $.each(response, function (i, item) {
                var img1 = '<a href="' + item.url1 + '"><img src="' + item.url1 + '"/></a>';
                var img2 = '<a href="' + item.url2 + '"><img src="' + item.url2 + '"/></a>';
    
                trHTML += '<tr><td>' + item.score + '</td><td>' + img1 + '</td><td>' + img2 + '</td></tr>';
            });
                // append results to table
                $('#resultsTable').append(trHTML);
          }
    < advertising removed by moderator >

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,522

    Re: how to display image in html table uisng jquery

    Three things:
    1) The amount of quotes you used in your jquery for the image is excessive...
    this
    Code:
    + "<td> <img src=" + "'" + "detail.gif" +"'" + "height=50 width=50> </td>" + "</tr>");
    should just be:
    Code:
    + "<td> <img src='detail.gif' height=50 width=50> </td>" + "</tr>");
    See how much easier that is to read?

    2) There's no need to use 20 question marks when one would have been sufficient. Also, a period would have been more appropriate since it was a statement, not an actual question.

    3) Te question about the div and image clicking are a completely different question and should have been in a new thread.

    4) Yes, I'm feeling a bit snarky and pedantic today, I haven't had my coffee yet.

    5) Yes, I realize that's more tan thee things.

    6) No I can't count, I thought that would be obvious by now.

    7) Help me! I can't stop making lists.

    8) eight s a nice round number, so this will assuage my OCD.


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width