0

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.

1
  • 3
    text: 'Taal', datafield: '<img src="http://www.site.nl/images/' + taal + '"/>', width: 50}, ? Commented Feb 18, 2014 at 12:37

2 Answers 2

3

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+'">'
Sign up to request clarification or add additional context in comments.

7 Comments

" = speech mark/double quote/quotation mark, ' = single quote/apostrophe
Aaah, that makes sense... Never seen it called that before :P
He is confused in quotes. :|
Still no succes. I have - { text: 'Taal', datafield: '<img src="gamepedia.nl/images' + 'taal' + '">', width: 50}, - But i get no image.
@user2959441 Why the semicolon before the first + ? You have '<img src="gamepedia.nl/images/'; + 'taal' + '">' which should be '<img src="gamepedia.nl/images/' + 'taal' + '">' (no ;)
|
0

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.

2 Comments

This is what i have now. Tried different sollutions... - { text: 'Taal', datafield: '<img src="site.nl/images/'+taal+'">', width: 50} - no succes however...
@user2959441 You don't want the ; - instead of ending taal+'">';, it should be taal+'">',

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.