Reputation: 175
Well, first start of with the code
JavaScript:
function keyevent(e) // submit key
{
if (e.keyCode == 13) // 13 = enter key
{
$(this).val("");
}
}
$(document).ready(function () {
$('#send').click(function() {
$('.message').val("");
});
});
HTML:
<input type="text" name="message" class="message" onKeyDown="javascript:keyevent(event);" />
<button name="send" id="send" onclick="refresh();" />Send</button>
Then I also have a if (isset($_POST['send')) higher up on my page. But when I then see the message I sent, the messagebox is empty because the value of message didn't exist.
So my question is, how do I "delay" the remove action? I have tried with delay()
Upvotes: 0
Views: 55
Reputation: 88707
Educated guess, what you need is this.
Javascript:
$(document).ready(function () {
$('.message').keyup(function(e) {
if (e.keyCode == 13) {
$(this).val('');
}
});
$('#send').click(function() {
refresh();
$('.message').val('');
});
});
HTML:
<input type="text" name="message" class="message" />
<button name="send" id="send">Send</button>
Upvotes: 1