Jquery .val() for input only works once.
- by Bolt_Head
I'm trying to create a chat box for my game.
The user type's their chat into the input:text feild and by ither pressing Enter or clicking the button submits the chat text.
This all works, however for some reason after the first time a user submits a chat message it fails to get the text from the input field.
Here is my code.
$(document).ready(function() {
	$("#chatEnter").live('click',function(){
		var chat = $('#chatText').val();
		sendChat(chat);
	});
});
$(document).ready(function() {
	$("#chatText").keypress(function(e){
		if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))
		{  
			var chat = $('#chatText').val();
			sendChat(chat);
			return false;
		}
		else return true;   
	});
});
function sendChat(chat)
{	
	alert(chat); //temp test alert
	$.getJSON("includes/boardUpdate.php",{chat: chat, bid: bid});
	$('#chatText').val("");
}
It doesn't matter if i first submit a text by clicking the button or pressing enter, all future attempts submit blank entrys until I refresh the page.
Edit: I've tried it with and without the line to clear the text box, same results both ways.
Your help is appreciated.