Solved

Issue with jQuery keydown

Posted on 2010-09-21
4
667 Views
Last Modified: 2012-08-13
Hi folks,

        I tried to bind an keydown event to the document, along with adding jScrollPane plugin.

        On keydown I wanted to move the focus to the input field (this was working fine), but later on I want to send this data to the server, so I added another keyUp event which would trigger the ajax call (code not present, instead I just put a alert box).

        After adding this alert box code, my code isnt working. Also in order to send whatever was read through the input to the server, do I need to enclose the INPUT tag in a form?
<script language="javascript">

$(function()

{

  $('.scroll-pane').jScrollPane();

});





$(document).keydown(function() {

   $('#serialInput').focus(); 

   $('#serialInput').keyup(function() {

     

	 alert(#serialInput.val());

   

   )};

  

});





</script>

Open in new window

0
Comment
Question by:t3ch
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
wuff earned 450 total points
ID: 33729912
You are missing $('..'). Try to add'em:

var myval = $('#serialInput').val();
alert(myval);

0
 
LVL 2

Assisted Solution

by:amischol
amischol earned 50 total points
ID: 33730074
I agree with wuff
0
 
LVL 4

Author Comment

by:t3ch
ID: 33730588
Hi Wuff,

                Its working now. Thanks. but what I changed was:

                       alert(#serialInput.val());
      )};
 
                to:

              alert(#serialInput.val());
     });
 

0
 
LVL 4

Author Closing Comment

by:t3ch
ID: 33978221
Thanks
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now