1

I have a table of 10 rows which has an image of a user in first column:

<table>
  <tr><td><img src='images/35067.png'/></td></tr>
  <tr><td><img src='images/35089.png'/></td></tr>
  .... <!-- more rows -->
</table>

the image file name is generated by the [id] of its data record within mysql. some users have no image assigned to them and the file dose not exists in the [images/] path. i would like to replace the invalid images with a default existing image like

src='images/default.png'

i have some conditions that the action must be done on the client side, not on server-side and it could be done aether with CSS or java-script.

Ehsan Zargar Ershadi
  • 24,115
  • 17
  • 65
  • 95
  • If you have to do it from client side, then maybe you have to check if that file exist using JavaScript. [This answer](http://stackoverflow.com/a/3646923/1706309) will help you with that. – pzin Apr 27 '13 at 11:40

1 Answers1

2

This would work

<img src='images/35067.png' onerror='this.src="images/default.png"'/>
Parthik Gosar
  • 10,998
  • 3
  • 24
  • 16