473,403 Members | 2,323 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,403 software developers and data experts.

submitting a form by pressing "ENTER"

Hi,

I have a very simple form and I would like on Firefox and IE for the
form to submit upon the user pressing enter in the textfield. Right
now, I have

<script type="text/javascript">
function search() {
var search = document.getElementById('Search');
location = "search_response.php?Search=" + escape(search.value);
} // search
</script>
<form name="search" action="javascript:search();" method="get">
<table cellpadding="2" cellspacing="0" border="0" width="100%">
<tr><td class="departmentSidebarTitle" style="height:25px;
padding-left:3px; padding-right:3px;" nowrap>Search Store</td></tr>
<tr><td class="departmentSidebar" width="100%" align="left"><input
type="text" name="Search" id="Search" value=""></td></tr>
</table>
</form>

(this is all within a table cell), but it is not working. However,
there are no JS errors. Any ideas how I can tweak the above to make it
work?

Thanks, -

Jun 29 '06 #1
1 2343

la***********@zipmail.com wrote:
Hi,

I have a very simple form and I would like on Firefox and IE for the
form to submit upon the user pressing enter in the textfield.
By default, all web forms will submit the form when a user presses
"Enter". There must be something else that's causing your form not to
behave correctly.
<form name="search" action="javascript:search();" method="get">
You are using the javascript pseudo protocol, which doesn't even belong
in the action attribute to begin with. Perhaps you meant the
following:

<form name="search" action="search_response.php" method="get">
<script type="text/javascript">
function search() {
var search = document.getElementById('Search');
location = "search_response.php?Search=" + escape(search.value);
} // search
</script>


In your javascript, this is entirely unecessary. Your form uses the
GET method, therefore, your values will already be sent in the manner
that you're trying to achieve in your script.

Jun 29 '06 #2

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

Similar topics

8
by: EBG | last post by:
I have a simple email form on my site but getting screwy results because I know alot of users are hitting "enter" instead of tab when doing the form. When they hit enter the entire form is...
4
by: Simon Wigzell | last post by:
Is there a way to prevent a form submitting when you press enter on a text field? Some people press enter when they finish typing in a text field out of habit I guess unconcsciously thinking it...
1
by: Byron McClain | last post by:
.... is being consumed. I added an event handler for the "keypress" event and my delegate never gets executed. Why? I am trying to catch the "enter" key pressed event to prevent the DataGrid...
2
by: Cindy | last post by:
Hi all you smarties out there, I'm having a little conundrum with my asp.net page Scenario: I have a form (asp.net) with no code behind (as yet). I have placed a javascript function on a...
0
by: roxanaislam | last post by:
Hi: I have a search form in my application which has 4 dropdown list controls, one text box, one "GO" button, one "reset" button. When the "GO" button is clicked the form gets submitted and the...
4
by: roxanaislam | last post by:
Submitting Form by pressing the "ENTER" key -------------------------------------------------------------------------------- Hi: I have a search form in my application which has 4 dropdown...
3
by: Zytan | last post by:
I can handle DoubleClick on a ListBox to respond, not when the selection changes, but when you double click one to invoke an action. This is the same as using the keys to move the selection, then...
0
by: vanipuranam | last post by:
When the user presses "Enter" from the keyboard instead of clicking the "Go" button I would like to have the code that would have run by clicking the button work the same way when they press the...
3
by: Simon Verona | last post by:
Sorry for the repost, but this group seems to be more "active" than the group that I posted my question, and it's probably as valid here as there! I have a usercontrol, which contains a textbox...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.