I have this Javascript:
Code
function buildChatLine(data) {
//console.log(data);
var $node = $('<tr class="tabelinhoud" id="'+data.id+'">' +
'<td><i>'+(new Date()).dateFormat('l, d/m/Y (H:i)', 'en', data.msg_time)+'</i></td>' +
'<td><a href="clientdetails.php?game=<?php echo $game; ?>'+
'&id='+data.client_id+'"></a> (' + data.msg_type + ' - Unknown)</td>' +
'<td class="msg"></td>'+
'</tr>');
$node.find('a').text(data.client_name);
$node.find('td.msg').text(data.msg);
if ( data.msg.charAt(0)=='!' || data.msg.charAt(0)=='@' ) {
$('td.msg', $node).css({'color':'#FF8000', 'font-weight':'bold'});
}
return $node;
}
It just grabs info from the database as it gets inserted and updates the page in real time. Now, I have this PHP code:
Code
<?php if($row_rs_chats['client_team'] == 3){
echo '<font color="red">Allies</font>';
}else if($row_rs_chats['client_team'] == 2){
echo '<font color="green">Axis</font>';
}else if($row_rs_chats['client_team'] == -1){
echo '<font color="grey">Spectator</font>';
}else{
echo 'Unknown';
}
?>
It should be pretty self explanatory, but if you're lost it will just display their team name instead of the number. For the Javascript part I have it set to just display "Unknown". What would I use for the Javascript to do what the PHP part is doing? Instead of having it always say "Unknown" as it updates I want it to display the actual team name.
I've always been sketchy with Javascript and haven't taken the time to properly learn it.
Thanks in advance!
This post was edited by Fakie on Apr 22 2013 09:33pm