473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

onKeyDown not working with Firefox

Ohhh Firefox.... I have created a javascript that when you click in a box to update a value, the submit button grays out and the update buttons is active. This works fine in IE and Safari as well as if i call the javascript from a drop down menu onChange it works fine, just when i do a onKeyPress or onKeyDown. I have been doing research on this all morning and getting tired of it. The closest thing i found was doing something like this, but i can not figure out how to get it to work with my script.


Expand|Select|Wrap|Line Numbers
  1. function EnterKey(e)
  2. {
  3.      var key;
  4.      if(window.event)
  5.           key = window.event.keyCode;     //IE
  6.      else
  7.           key = e.which;     //firefox
  8.  
  9.      if(key == 13)
  10.           return true;
  11.      else
  12.           return false;
  13. }
  14.  
  15.  
Here is my input...

Expand|Select|Wrap|Line Numbers
  1. <input size="2" tabindex="2" onkeydown="validate();" onblur="setFocus()"  type="text" maxlength="3" name="qty<?php echo $prod_key; ?>" value="<?php echo $qty; ?>"/>   

Here is my javascript to gray out the submit button and show the update button.
Expand|Select|Wrap|Line Numbers
  1. function validate( the_form ) {  
  2.  
  3.     var x=document.getElementById('update');
  4.     var y=document.getElementById('sale_pass');    
  5.     var z=document.getElementById('reason');
  6.     var hide=document.getElementById('hide');
  7.     var hide_r=document.getElementById('hide_r');
  8.     var sale=document.getElementById('sale_type');
  9.     var car=document.getElementById('complete');
  10.  
  11.     car.disabled = true;
  12.     x.style.visibility = 'visible';
  13.     if(sale.value != 'sale') {
  14.         y.style.visibility = 'hidden';
  15.         z.style.visibility = 'hidden';
  16.         hide.style.visibility = 'hidden';
  17.         hide_r.style.visibility = 'hidden';
  18.     }
  19.     //x.focus();
  20. }
  21. </script>
Dec 23 '10 #1
1 3293
Dormilich
8,658 Expert Mod 8TB
probably something like
Expand|Select|Wrap|Line Numbers
  1. // input is your input element
  2. input.onkeydown = EnterKey;
  3.  
  4. // somewhere inside EnterKey() you have to call validate()
Dec 25 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: sonic_soul | last post by:
Hi, I was curious if I could make my webservice work with firefox client webservice functionality. (i got it to work with webservice.htc) I am able to get firefox to see my serverside web...
3
by: TJS | last post by:
I am finding that the serverside requiredvalidator doesn't fire in the firefox browser, and user request proceeds through to my updateProfile method. Validation is working correctly in the IE...
10
by: Paul Gorodyansky | last post by:
Hi, Ran into the problem today - in INPUT field Firefox executes clean-yp of the content if a user presses Esc, _before_ control goes to the code via onkeydown - and search showed that it's a...
8
by: Marcin Nowak | last post by:
Hi! I want to cancel up and down arrows in list (select) element. Here is the code: <script> function Arrows (event) { code = event.keyCode;
2
by: ra88it | last post by:
I'm working on some javascript games, and I encountered what appears to be a bug specific to Firefox on Linux (I'm using several recent versions of Ubuntu). I'd love to get some help verifying...
1
eboyjr14
by: eboyjr14 | last post by:
I have this UserScript for Grease monkey. but I can't get the onleydown event to fire in FIREFOX only. I've looked everywhere! // ==UserScript== // @name iGoogle Suggest //...
3
by: geetha v | last post by:
Hi All, I need a scrolling DIV is a to display my dynamic tree in left frame. In my jsp , Div overflow is set to "auto" <DIV id=divScroller style="overflow:auto;height:200px"> <!--...
3
rajiv07
by: rajiv07 | last post by:
<html> <head> <title><%=strTitle%></title> <script language="JavaScript"> <!-- var message="Sorry, that function is disabled."; function onKeyDown(e) { if (event.keyCode == 122) {
3
by: gjain12 | last post by:
Hi all, I am using the following code to disable the ctrl+a/c/v/x keys. <html> <head> <script language="JavaScript" type="text/javascript"> function disableCtrlKeyCombination(e) { //list...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.