javascrip question mixed with php?

  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 675
  • Loc: Conroe, Texas

Post 3+ Months Ago

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????
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

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>

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 108 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
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.