473,320 Members | 1,887 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,320 software developers and data experts.

using the key handling function

Hello

I have a piece of simple code which take the user inputs and depending
which check box is selected directs them to a different page.

<form name="allform">
<input type="radio" name="allsearch" value="Weaksearch">
<font face="Arial,Helvetica" >Weak&nbsp;</font><br>
<input type="radio" name="allsearch" value="Pinsersearch">

<font face="Arial,Helvetica" >Pinser&nbsp;</font><br>
<input type="radio" name="allsearch" value="Brutesearch">
<font face="Arial,Helvetica">Brute note&nbsp;</font> <br>
<input type="radio" name="allsearch" checked
value="gogsearch">
<font face="Arial,Helvetica">Google</font> <br>
<input type=text name=allsearchtext size=10 maxlength=255>

<input type="button" onClick="locateall(this)" value="Go"
name="button">
</form>

This works but the user needs to hit the go button, if they just hit
return the text field is emptied, I would like if the user hits ENTER,
the search begins.

I believe I can add something similar as

if (window.event.keyCode == 13)

But I am not sure how to incorporate it in the form?
--

Jul 20 '05 #1
3 2631
Paul Kirk <pa*******@xilinx.com> writes:
<input type="button" onClick="locateall(this)" value="Go"
name="button"> .... This works but the user needs to hit the go button, if they just hit
return the text field is emptied,
What happens is that the form is submitted. The missing (and
required!) action attribute is interpreted as pointing to the page
itself, so the page is reloaded.
I would like if the user hits ENTER, the search begins. I believe I can add something similar as

if (window.event.keyCode == 13)


Overkill.
Just put the call to locateall in the onsubmit handler of the form tag:

<form id="allform" onclick="locateall(this)" action="noJS.html">
(fix the locateall function so it expects the form as argument and not
the button).

Change the <input type="button" ...> to
<input type="submit: value-"Go" name="button">

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
In article <3F***************@xilinx.com>, pa*******@xilinx.com
enlightened us with...
This works but the user needs to hit the go button, if they just hit
return the text field is emptied, I would like if the user hits ENTER,
the search begins.

I believe I can add something similar as

if (window.event.keyCode == 13)

But I am not sure how to incorporate it in the form?

You don't need to - the enter key is submitting the form.
Try this.

<form name="allform" onSubmit="locateall(this);return false;">

Your Go button calls that function onClick - so you may need to play
with the "this" keyword, which refers to the button when the button is
clicked but to the form when the enter key is pressed and the form is
submitted.

--
-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #3
Thank you that worked a treat.

kaeli wrote:
In article <3F***************@xilinx.com>, pa*******@xilinx.com
enlightened us with...
This works but the user needs to hit the go button, if they just hit
return the text field is emptied, I would like if the user hits ENTER,
the search begins.

I believe I can add something similar as

if (window.event.keyCode == 13)

But I am not sure how to incorporate it in the form?


You don't need to - the enter key is submitting the form.
Try this.

<form name="allform" onSubmit="locateall(this);return false;">

Your Go button calls that function onClick - so you may need to play
with the "this" keyword, which refers to the button when the button is
clicked but to the form when the enter key is pressed and the form is
submitted.

--
-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------


--
Regards
Paul Kirk
/ /\/ Paul Kirk Xilinx Inc.
\ \ Customer Apps Engineer 203 Brooklands Road
/ / Pa*******@xilinx.com Weybridge Surrey KT13 0RH
\_\/\ Eu*********@xilinx.com http://support.xilinx.com
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
4
by: James Radke | last post by:
Hello, I am looking for guidance on best practices to incorporate effective and complete error handling in an application written in VB.NET. If I have the following function in a class module...
33
by: Anthony England | last post by:
I am considering general error handling routines and have written a sample function to look up an ID in a table. The function returns True if it can find the ID and create a recordset based on...
10
by: Anthony England | last post by:
(sorry for the likely repost, but it is still not showing on my news server and after that much typing, I don't want to lose it) I am considering general error handling routines and have...
40
by: Mark P | last post by:
I'm implementing an algorithm and the computational flow is a somewhat deep. That is, fcn A makes many calls to fcn B which makes many calls to fcn C, and so on. The return value of the outermost...
7
by: Darko | last post by:
Hello, I have this particular problem with eval() when using Microsoft Internet Explorer, when trying to define an event handler. This is the code: function BigObject() { this.items = new...
9
by: Chad | last post by:
This might be a bit vague and poorly worded..... In my program, I handle function failures using fprintf() and exit() like: fprintf(stderr, "malloc failed"); exit(EXIT_FAILURE); There...
0
by: Lysander | last post by:
Thought I would give something back with a few articles. This article is a bit of code to add error handling. When I have time, I want to write articles on multilingual databases, and Access...
1
by: George2 | last post by:
Hello everyone, Such code segment is used to check whether function call or exception- handling mechanism runs out of memory first (written by Bjarne), void perverted() { try{
0
by: srizzler | last post by:
Hi All: I am trying to implement Exception Handling using Enterprise Library 3.1's Exception Handling Application Block as well as Logging Blocks. I have a windows application developed in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.