1

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;

         }
    });
}); 
3
  • $('testingHuss').val('') will empty the input. Call that when you are done with the data inside Commented Apr 10, 2015 at 21:00
  • If you're using jQuery please add the tag. Commented Apr 10, 2015 at 21:01
  • thanks for your quick response can you please tell me where exactly Commented Apr 10, 2015 at 21:04

3 Answers 3

1

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/

Sign up to request clarification or add additional context in comments.

Comments

0

document.test.msg1.value =""

Before return false

Comments

0

Since you're using jquery replace this line:

updateTextInput(session, "testingHuss", value = "")

with:

$('.testingHuss').val('');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.