0

The below line of code is not working in my php page causing the page not to load. The line works fine in html and the image appropriately changes

        $content[] = '<div id="dealslist" onclick="godea('.$row['id'].');" style="border-bottom:1px solid gray;padding:2px;width:180px;float:left;">
                        <div style="width:100%;float:left;">
                            <h4 style="margin:0;"><span style="float:left;">'.$row['fname'].'</span></h4><div style="width:100%;float:left;"  ><p><b>Address:</b></p><span id="eventaddr" onclick="gomap();" style="color:#1D77EF;">'.$row['addr1'].', '.$row['addr2'].'<br/>'.$row['city'].', '.$row['state'].' '.$row['zip'].'</span></div><br /><p style="margin-bottom:0;">'.substr($row['description'],0,300).'</p>
                        </div>
                                     </div><br /></br><a onclick="document.getElementById('myImage').src='fav2.png'"><img id="myImage" src="fav.png" style="opacity: 0.7;height:45px;max-width:100px"></a>
                    ';

using (\'myImage\').src=\'fav2.png\' also does not work

Answerme
  • 21
  • 3
  • Open developer tools and see if you are getting any errors. Might suggest what the problem is! – Dragomir Kolev Aug 12 '17 at 23:18
  • @DragomirKolev i am using notepad, i am not sure if that program has developer tools. I am a self taught coder – Answerme Aug 12 '17 at 23:20
  • Developer tools runs in the browser. Press f12 if you are using chrome. Google how to get dev tools if using other browser as im not sure – Dragomir Kolev Aug 12 '17 at 23:21
  • This might answer your questions. Check out the answer on this link https://stackoverflow.com/questions/19323010/execute-php-function-with-onclick – Dragomir Kolev Aug 12 '17 at 23:26
  • Post your php part! Not just the html part. The code you posted seems to be valid. So nobody will find an error in it. You need your quotes to be properly escaped. And you should recognize that you wont get those problems is you assign your event handlers with jquery.on(). That should always be the preferred way. – steven Aug 12 '17 at 23:46
  • @steven I added more code, I hope this helps – Answerme Aug 13 '17 at 00:54
  • I found my own answer, all I had to do is replace the ' with ` @steven @Dragomir Kolev thank you for your help – Answerme Aug 13 '17 at 01:37
  • @steven I found my own answer, all I had to do is replace the ' with ` thank you for your help – Answerme Aug 13 '17 at 02:09
  • @DragomirKolev I found my own answer, all I had to do is replace the ' with ` thank you for your help – Answerme Aug 13 '17 at 02:09

0 Answers0