Reputation: 37
I have some JavaScript code to display values from a mysql database.
columns: [
{ text: 'Taal', datafield: 'taal', width: 50},
{ text: 'Titel', datafield: 'titel', width: 690 },
{ text: 'Website', datafield: 'sitenaam', width: 180 },
{ text: 'Ingezonden Door', datafield: 'gamer_int', width: 150 },
{ text: 'Datum', datafield: 'datum', width: 100 }
]
When we look at the first column named "Taal"
the mysql database contains a value like eng_ico.png
. What I want is something like this so the results display that image.
columns: [
{ text: 'Taal', datafield: "<img src=\"http://www.site.nl/images/" 'taal' "\">, width: 50},
{ text: 'Titel', datafield: 'titel', width: 690 },
{ text: 'Website', datafield: 'sitenaam', width: 180 },
{ text: 'Ingezonden Door', datafield: 'gamer_int', width: 150 },
{ text: 'Datum', datafield: 'datum', width: 100 }
]
I cannot get this right. Don't know what I am doing wrong. I tried the " . 'taal' . "
like in php but also no success.
Upvotes: 0
Views: 68
Reputation: 2708
You have used quotes wrongly. See the following code
columns: [
{ text: 'Taal', datafield:'<img src="http://www.site.nl/images/'+taal+'">', width: 50},
{ text: 'Titel', datafield: 'titel', width: 690 },
{ text: 'Website', datafield: 'sitenaam', width: 180 },
{ text: 'Ingezonden Door', datafield: 'gamer_int', width: 150 },
{ text: 'Datum', datafield: 'datum', width: 100 }
]
Hope it helps.
Upvotes: 0
Reputation: 10838
Firstly, your string didn't have an ending speech mark, and the concatenation is done slightly different to PHP, using +
instead of .
(also I'd use single quotes to remove the need for escaping with backslashes)
'<img src="http://www.site.nl/images/'+taal+'">'
Upvotes: 3