javascrip question mixed with php?

  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Joined: Jun 21, 2006
  • Posts: 485
  • Loc: Conroe, Texas
  • Status: Offline

Post May 21st, 2011, 5:22 am

I am having issues with this....


Code: [ Select ]
<? $id = $myid['id']; ?>
<a href="javascript:handleParent("$id")">Comment</a>
  1. <? $id = $myid['id']; ?>
  2. <a href="javascript:handleParent("$id")">Comment</a>


it dont work. is there anyway to make it work????
Thanks, Josh --DemonMaestro
www.LilNetwork.com
Fun Website www.ShoutsCloud.com
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post May 21st, 2011, 5:22 am

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post May 21st, 2011, 7:10 am

Remember, PHP is a "pre-processor". Nothing about PHP itself exists by the time Javascript is executed, only the things PHP generated before sending the page to the browser are known to Javascript.

To make what you have work, you need to surround that $id you have on the second line in PHP opening and closing delimiters like you have on the first line. On the second line however, you'll use echo/print/etc to tell PHP that it should print the string value of $id right there.


For instance;

Code: [ Select ]
<? $id = $myid['id']; ?>
<a href="javascript:handleParent("<? echo $id; ?>")">Comment</a>
  1. <? $id = $myid['id']; ?>
  2. <a href="javascript:handleParent("<? echo $id; ?>")">Comment</a>
Strong with this one, the sudo is.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 98 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.