我想将一个php变量传递给我的LinkONCLick4函数,但由于某种原因,该变量未被传递给conversation.php,该函数甚至无法工作。我早先在我的一个网页上使用了相同的功能,并且它运行良好;我不明白为什么现在不工作。我任何人都可以帮助我,这将是伟大的!将一个变量从php传递到javascript
<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>
尝试onclick =“LinkOnClick4(\'你好\')” – redmoon7777 2012-01-13 20:34:03
'onclick =“LinkOnClick4(”你好“)”'显示了很多双引号...... – Grooveek 2012-01-13 20:34:13
哦,废话的家伙,它肩d已经说过onclick =“LinkOnClick4('。$ users。'”) – Eggo 2012-01-13 20:35:06