Reputation: 21
I have a webpage that I'm using to update a value remotely. To be more specific, on one side, I have a screen connected to the internet with a little field in it that reads (Now Serving: ##) and on the other side, I have a tablet connected to the internet with a webpage that is used to push the value to the screen and update it. Everything looks good except the following: Getting the input field to clear after it submits the value so I can type another number in it without the need to manually clear it
Below is my HTML Code
<div id="container">
<div id="logoDiv"></div>
<h3>Type the number in the box</h3>
<div class="theWork">
<div id="formDiv">
<FORM NAME="test" class="theForm">
Now Serving: <input type="text" name="msg1" class="testingHuss" id="theOrderBox" autofocus ><br>
</FORM>
</div>
<div id="onScreenDiv"><span id="onscreen"></span></div>
</div>
</div>
and here is my JavaScript code
$(document).ready(function() {
$('.testingHuss').keydown(function(event) {
if (event.keyCode == 13) {
sendCommand("galaxy.signage.me", "wmt_huss", "husshuss", "3", "nowServing", document.test.msg1.value);
document.getElementById('onscreen').innerHTML = document.test.msg1.value;
return false;
}
});
});
Upvotes: 1
Views: 835
Reputation: 2809
Since you are using Jquery you can do it like this:
$(document).ready(function() {
$('.testingHuss').keydown(function(event) {
if (event.keyCode == 13) {
//Do Necesary stuff when enter was pressed.
$(event.currentTarget).val('');
}
});
});
Fiddle: https://jsfiddle.net/fgqs4hzb/
Upvotes: 1
Reputation: 301
Since you're using jquery replace this line:
updateTextInput(session, "testingHuss", value = "")
with:
$('.testingHuss').val('');
Upvotes: 0