tazeha Posted December 5, 2015 Share Posted December 5, 2015 (edited) I use java script code to disable click on link in php but not working onclick="return false" I use tow way for add java script code to php link but both not working.. First way: $data .= '<td bgcolor="FFFFCC">'."<a href='http://priceha.ir/' onclick=\"return false\">.$row2->model.</a>".'</td>'; The second way: $data .= '<td bgcolor="FFFFCC">'."<a href='http://priceha.ir/' onclick='return false'>.$row2->model.</a>".'</td>'; Edited December 5, 2015 by tazeha Link to comment Share on other sites More sharing options...
Ingolme Posted December 5, 2015 Share Posted December 5, 2015 Both of those examples should work. If they're not working then perhaps you're not actually printing $data to the page. I'd have to see your page to figure out why it's not working. The bgcolor attribute is not standard, you should be using CSS to give a background color. You also have forgotten the # symbol next to the hexadecimal code, at the very least it should be bgcolor="#FFFFCC" Link to comment Share on other sites More sharing options...
dsonesuk Posted December 6, 2015 Share Posted December 6, 2015 Do you want a period either side of $row2->model? because you have not escaped html text string, it should be $data .= '<td bgcolor="#FFFFCC">'."<a href='http://priceha.ir/''>http://priceha.ir/' onclick=\"return false\">".$row2->model."</a>".'</td>'; If you wish to retain html double quotes without escaping all the time (however if passing string value to js function you will need to escape single quotes) use single quotes for html string $data .= '<td bgcolor="#FFFFCC"><a href="http://priceha.ir/" onclick="return false">'.$row2->model.'</a></td>'; Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now