私はこれに対する答えを見つけることができず、それは私を長く取っています これは私の問題です:PHPの変数をjavascript onclickに渡したいのですが、 1つの変数に姓と名字を渡すなどの変数の値の間のスペースは機能しませんが、1つのユーザー名を渡すことは機能しています。phpからjavascriptまでのスペースで値を渡すonClick
//$username='Liberty Johnson';//This one is not working
$username='LibertyJohnson';
<tr>
<td><b>
<?php echo $username?>
</b> is online now <a href="javascript:void(0)"
onclick= "javascript:chatWith('<?php echo $username?>')">
Start Chat</a>
</td>
</tr>
function chatWith(chatuser) {
createChatBox(chatuser);
$("#chatbox_" + chatuser + " .chatboxtextarea").focus();
}
の
<?php echo str_replace(' ', ' ', $username); ?>
を使用することができますが、 'chatWith'で何をしているのか? –
関数chatWith(chatuser){ \t createChatBox(chatuser)。 \t $( "#chatbox _" + chatuser + ".chatboxtextarea")。フォーカス(); } – Leereal
多分それは@ MurtazaKhursheedHussainを助けることができる – Leereal