Google Answers Logo
View Question
 
Q: Javascript function call ( No Answer,   1 Comment )
Question  
Subject: Javascript function call
Category: Computers > Internet
Asked by: ted2000-ga
List Price: $5.00
Posted: 04 Jul 2006 14:12 PDT
Expires: 03 Aug 2006 14:12 PDT
Question ID: 743341
One of my form in pure HTML has 1 text input field and 2 buttons.
Pressing one of the buttons triggers a search-me() function.

I'm also using the following script activated on a onkeydown event to
ensure that the search-me function is also called when pressing ENTER
after something in the input text field is entered. Everything should
work exactly as if the user had pressed the button.

Script used:

function submitenter(e){
var keynum;
if(window.event) { //IE
keynum = e.keyCode;}
else if(e.which){ // Netscape/Firefox/Opera
	keynum = e.which;}
if (keynum == 13) { // 13 = value of ENTER key
	msg = 'Searching'; //NOTE1
	alert(msg); //NOTE1
	search-me();}}

PROBLEM:
- no problem with IE, including if I deactivate the lines that have
NOTE1 at the end.
- problem in Firefox 1.5.x if I deactivate the lines have NOTE1 at the end.

The lines with NOTE1 at the end should not be used in the real world.
I had those in the script for debugging purposes, showing a message +
the value of the key pressed.

But when I deactivate them, it no longer works in FF. Where is the
bug? The search-me function includes a URL redirection such as
window.location = searchurl.

Request for Question Clarification by palitoy-ga on 05 Jul 2006 00:52 PDT
Hello ted2000-ga,

It would be helpful to also see the coding you have for the form that
calls your submitenter function in case the error lies there.  Can you
provide this for us?  The perfect clarification would have the whole
HTML page complete with all of your javascript functions!

It is always difficult to debug only a partial webpage as we have to
try to replicate the rest of your page without knowing exactly what
you are doing - this takes time and as your question is only a $5 one
this is something researchers may look over as "not worth it for the
time and effort required".  See:
http://answers.google.com/answers/pricing.html

palitoy-ga
Answer  
There is no answer at this time.

Comments  
Subject: Re: Javascript function call
From: crythias-ga on 11 Jul 2006 13:48 PDT
 
Try this:
function submitenter(e){
var keynum;

if(window.event) { //IE
keynum = window.event.keyCode;}
else if(e){ // Netscape/Firefox/Opera
	keynum = e.which;}
if (keynum == 13) { // 13 = value of ENTER key
	msg = 'Searching'; //NOTE1
	alert(msg); //NOTE1
	search-me();}
	}

-=-=-
onkeydown="submitenter(event)"

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy