0

I am trying to pass a php variable to my LinkONCLick4 function, but for some reason, the variable is not being passed to conversation.php and the function does not even work. I used this same function earlier on one of my web pages and it worked fine; I don't why it is not working now. I anyone could help me that would be great!

<script>
    function LinkOnClick4(box) {
    $('#friendresults').load('conversation.php?id=' + box);
    }
    </script>
    <div id='showfriends' style='display:none;'>
    <div style="margin-top:5px;"><input type='text' name='searchfriends' id='searchfriends' class='searchfriends' autocomplete="off" value="Search for a friend..." onClick="this.style.border = '1px solid #4F94CD'; document.getElementById('friendresults').style.visibility = 'visible';" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue; this.style.border = '1px solid #5E5E5E';" onkeyup='searchfriends()'/></div>
    <div id='hrdiv3'></div>
    <div id='friendresults' name='friendresults' style='float:left;'>
    <?php
    $construct = "SELECT * FROM acceptedfriends WHERE profilename='$profilename' ORDER BY id DESC LIMIT 6";
    $run = mysql_query($construct);
    $foundnum = mysql_num_rows($run);
    while ($runrows = mysql_fetch_assoc($run))
    {
    $users = $runrows['username'];
    $location = $runrows['imagelocation'];
    $image = "<img src='$location' style='width:60px; height:40px;' />";
    if ($profilename==$username)
    {
    echo '<div id="hovercolor2" onclick="LinkOnClick4('.$users.')" style="width:294px; float:left;"><table><tr><td>'.$image.'</td><td><div style="margin-bottom:5px;"><a href="http://www.pearlsquirrel.com/'.$users.'" target="_blank">'.$users.'</a></div><div><a href="http://www.pearlsquirrel.com/conversation.php/'.$pageusers.'" style="text-decoration:underline;" target="_blank"><div style="font-size:.7em";>Click to enter a conversation.</div></a></div></td></tr></table></div><div id="hrdiv3" style="float:left; width:298px;"></div>';
    }
    else
    {
    echo '<div id="hovercolor2" style="width:294px; float:left;"><table><tr><td>'.$image.'</td><td><a href="http://www.pearlsquirrel.com/'.$users.'" target="_blank">'.$users.'</a></td></tr></table></div><div id="hrdiv3" style="float:left; width:298px;"></div>';
    }
    }
    ?>
    </div>
    </div>
    </div>
    </div>
</div>

Eggo
  • 541
  • 7
  • 18

1 Answers1

1

Try replace your line with this

echo '<div id="hovercolor2" onclick="LinkOnClick4(\'' . $users . '\')" style="width:294px; float:left;"><table><tr><td>'.$image.'</td><td><div style="margin-bottom:5px;"><a href="http://www.pearlsquirrel.com/'.$users.'" target="_blank">'.$users.'</a></div><div><a href="http://www.pearlsquirrel.com/conversation.php/'.$pageusers.'" style="text-decoration:underline;" target="_blank"><div style="font-size:.7em";>Click to enter a conversation.</div></a></div></td></tr></table></div><div id="hrdiv3" style="float:left; width:298px;"></div>';

Except for that, everything looks fine and I'm unable to find anything else that might be cause of the problem

Tom
  • 3,450
  • 22
  • 31
  • You my good sir are amazing. Thanks so much for the help. The solution that I spent two hours trying to solve last night was fixed in 5 minutes here. I really appreciate it! – Eggo Jan 13 '12 at 20:39
  • @Eggo - No problem at all :) Glad to help! Please click the "tick" next to my question to let others know that the question has been solved :) – Tom Jan 13 '12 at 20:41
  • I know, but I says that I can not click it for another four minutes. – Eggo Jan 13 '12 at 20:41