I am failing to find the answer for this and it is taking me long This is my problem: I want to pass php variable to javascript onclick but i am failing if there is space between the value of the variable for example passing first name and last name in one variable is not working but passing one username is working.
This is the code:
//$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();
}
chatWith?function chatWith(chatuser) { createChatBox(chatuser); $("#chatbox_"+chatuser.replace(" ", "")+" .chatboxtextarea").focus(); }