Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-01-2009, 06:57 PM   PM User | #1
anikar
New to the CF scene

 
Join Date: Jun 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
anikar is an unknown quantity at this point
Form not posting on clicking enter on keyboard

I have not been codeing for too long. The form submits correctly when the button is pressed bu wheni click enter on keyboard it gives a page not foud error

here is the code

Code:
function ByPartNo(){
	var strTest = document.form1.search_criteria.value;
	if (strTest){ 
		document.form1.action="result_details_by_part_no.asp?mSKU="+ strTest 
		document.form1.submit();
	}else{
		alert("Please Enter a Valid ID.")
	}	
}


<form id="form1" name="form1"  method="post">
   <input name="search_criteria" type="text" id="search_criteria" size="25" /></td>
                      <td width="42%" style="border-style: none; border-width: medium">&nbsp;<a href="javascript:ByPartNo()"><img src="images/search_button.gif" width="105" height="26" border="0" /></a></td>
</form>
Any help would be appreciated. Thanks in advance
anikar is offline   Reply With Quote
Old 06-01-2009, 07:15 PM   PM User | #2
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
For a form to submit on hitting enter, you'd need form action to be present, rather than being set via JavaScript. Otherwise, you're going to need an event handler in every field that will monitor for the enter key and if it fires, execute the JS function you have. You could always re-name the search_criteria field to mSKU instead and get rid of the JS completely, adding a form action of the web-page you need to post your information to. Otherwise... you're not really doing a POST with your code, it's more doing a POST to a web-page which has the GET variables pre-filled.
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?
Eldarrion is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:25 PM.


Advertisement
Log in to turn off these ads.