By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,654 Members | 1,513 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,654 IT Pros & Developers. It's quick & easy.

What is the proper link syntax of javascript in PHP?

P: 34
I am trying to create a new link in a javascript function which is in a PHP file. The portion of code that works correctly is:

Expand|Select|Wrap|Line Numbers
  1. <span class=\"title_txt\">
  2. ‣<a href=\"javascript:openPosting("
  3. . $eventdata[$day]["id"][$j] . ")\">"
  4. . $eventdata[$day]["title"][$j] . "</a></span><br>";
I tried creating a link with a new onclick event. It returns aParse error: syntax error, unexpected T_CLASS. I am guessing it has to do with the quotations but I am unsure. The code is below:

Expand|Select|Wrap|Line Numbers
  1. <span class=\"title_txt\">
  2. ‣<a href=\"#\" onclick=\"TINY.box.show({url:login.php,width:200})\">". $eventdata[$day]["title"][$j] . "</a></span><br>";
Apr 14 '11 #1

✓ answered by acoder

Surely login.php should be in quotes:
onclick=\"TINY.box.show({url:'login.php',width:200 })\">"If that doesn't work, post the generated code on the client.

Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Surely login.php should be in quotes:
onclick=\"TINY.box.show({url:'login.php',width:200 })\">"If that doesn't work, post the generated code on the client.
Apr 14 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.