echo "<br><font face='Segoe UI' color='blue'><a href='#' onClick='javascript:alert(".$nam.");return false;'>".$nam."</a></font>";
I’d like to know if there’s any syntax error in the above code. I don’t think alert() is being called.
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Let us say you have
This prints out:
That is, it is trying to print out a javascript variable e.g. “test” that was never initialized.
You need to have:
Now several recommendations:
Get a good Javascript debugger such as Firefox’s Web Developer toolbar or firebug. You could see the issue immediately.
Don’t use the ‘javascript:’ decleration. It is deprecated and unnecessary.
Use onclick, not onClick.
The font tag is deprecated as are the face and color attributes.
Close your tags (<br /> vs <br>).
Don’t infuse javascript, php, and html. I highly recommend you use a template.
If you are using weak quotes (“, not ‘) php will interpolate variables within the quotes. You don’t have to concatenate. These are equivalent: