title: Passing php string of a friend's name to javascript function
body: <p>I'm trying to pass a php string to a javascript function. The php portion looks like this:</p>
  
  <pre><code>&lt;?php
     foreach ($friends as $key =&gt; $friend) {
     // Extract the pieces of info we need from the requests above
     $id = assertNumeric(idx($friend, 'id'));
     $name = idx($friend, 'name');
     // Here we link each friend we display to their profile
     echo('
       &lt;li&gt;
       &lt;a href="#" onclick="window.open(\'http://www.facebook.com/' . $id . '\')"&gt;
       &lt;img src="https://graph.facebook.com/' . $id . '/picture?type=square" alt="' . $name . '"&gt;'. $name . '
      &lt;/a&gt;
      &lt;form&gt;
      &lt;input type="button" value="Meet" onclick="postMeet(. $name.)"/&gt;
      &lt;/form&gt;
      &lt;/li&gt;');
      }
  ?&gt;
  </code></pre>
  
  <p>The javascript function looks like this. It works perfectly if I pass either $key or $id to the function but not passing $name. Anyone got any ideas? I'm pretty new to php and javascript.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function postMeet(key)
  {
          var met = 'Met ';
          var body = met + ' '+ key;
          FB.api('/me/feed', 'post', { message: body }, function(response) {
                 if (!response || response.error) {
                 alert(response[0]);
                 alert('Error occured');
                 } else {
                 alert('Post ID: ' + response.id);
                 }
                 });           
  }
  &lt;/script&gt;
  </code></pre>