-
Apr 27th, 2013, 10:51 PM
#1
Thread Starter
Fanatic Member
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
-
Apr 27th, 2013, 11:48 PM
#2
Thread Starter
Fanatic Member
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
-
Dec 2nd, 2013, 09:54 AM
#3
Thread Starter
Fanatic Member
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
-
Feb 12th, 2020, 11:13 PM
#4
Member
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 >
-
Feb 13th, 2020, 08:00 AM
#5
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
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|