<script language="JavaScript">
var GetChatUrl = "getChatData.php";
var SendChatUrl = "sendChatData.php";
var lastID = -1;
function loadSetting(){
checkName();
getChat();
}
function checkName() {
var currentName = document.getElementById('name');
if (currentName.value == "") {
currentName.value = "{$_G[member][username]}";
}
}
function getChat(){
var param = "lastID="+lastID;
postDataReturnText(GetChatUrl,param,displayChat);
}
function displayChat(text){
results = text.split('---');
if (results.length > 2) {
for(i=0;i < (results.length-1);i=i+4) {
document.getElementById("chatroom").innerHTML += "<div><u>"+results[i+1]+ "</u>("+ results[i+3].substring(11,19)+") said : "+results[i+2]+"</div><br>";
}
lastID = results[results.length-5];
}
document.getElementById("chatroom").scrollTop = 50000;
}
function sendComment(){
var currentChatText = document.getElementById('chatbarText').value;
var currentName = document.getElementById('name').value;
var param = 'name='+ currentName+'&text='+ currentChatText;
postDataReturnText(SendChatUrl,param,getChat)
document.getElementById('chatbarText').value = "";
document.getElementById('chatbarText').focus();
}
function clearComment(){
var currentChatText = document.getElementById('chatbarText').value;
var currentName = document.getElementById('name').value;
var param = 'name='- currentName+'&text='- currentChatText;
postDataReturnText(SendChatUrl,param,getChat)
document.getElementById('chatbarText').value = "";
document.getElementById('chatbarText').focus();
}
</script>
ทีนี้จะทำยังไงให้กด Enter แล้วมันส่งข้อความ เหมือนกดปุ่ม ส่งข้อความ อ่าครับ ?