user2338456
user2338456

Reputation: 520

output html with echo

i am echoing html with php echo

for example :

echo "<span onClick='popUpWin('add_page.php?id=".$row[Id]."', 'standard', '1000', '600',30,150)'><img src='images/editbtn.png' class='ddpngfix'></span>";

it is displaying data as it should be, my problem is when i click on image it is not calling function popUpWin, it is present on the same page, and when i checked in firebug inspect element it is showing span element totally broken, please check below image

enter image description here

i know quotes are making problem , How to solve this ?

Upvotes: 0

Views: 79

Answers (2)

Sougata Bose
Sougata Bose

Reputation: 31739

Escape the 's properly -

echo "<span onClick=\"popUpWin('add_page.php?id=".$row['Id']."', 'standard', 1000, 600 ,30,150)\"><img src='images/editbtn.png' class='ddpngfix'></span>";

No need for 's around numbers.

Upvotes: 4

Hardik Solanki
Hardik Solanki

Reputation: 3195

Add " for onclick and escape it like below:

echo "<span onclick=\"popUpWin('add_page.php?id=".$row['Id']."', 'standard', 1000, 600 ,30,150)\"><img src='images/editbtn.png' class='ddpngfix'></span>";

Upvotes: 4

Related Questions