There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot browser bsod computer cpu crash css dell desktop driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware missing monitor network networking outlook outlook 2003 outlook 2007 outlook express password popups problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Input with no form


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,196 posts.
 
Join Date: Oct 2006
06-Jun-2007, 09:09 AM #1
Input with no form
Hi, I have a text box and submit button but no <form> tag (does a javascipt action).

The problem with this is that when I press enter in the text box it doesn't press the submit button.

Does anybody know how to fix this?

I don't want to add the form tag because it adds a line break.
__________________
Guys, please, this is free tech support, act accordingly.

afk for a while
haswalt's Avatar
Computer Specs
Senior Member with 398 posts.
 
Join Date: Nov 2004
Location: South Coast, UK
Experience: Advanced
06-Jun-2007, 10:18 AM #2
add the form tag like this to remove the line break:

HTML Code:
<form method="post" actions="" name="myForm" style="display:inline;">
Your form here
</form>
or use a key listener:

Two ways to do this, use and individual function to check for key presses assigned to the form elements, ie

HTML Code:
<input type="text" onkeypress="checkEnter();" />
or add and overal handler to check for the enter key and the currently focussed element.

Here is some script to implement the fisrt option:

For Script:
HTML Code:
<script>
function checkEnter() {
     if (window.event && window.event.keyCode == 13)
          //do your submission stuff
     else
          //ignore the keypress and carry on
        return true;
}
</script>
For form:
HTML Code:
<input type="text" onkeypress="checkEnter();" />
__________________
LQD Internet Limited
We've just got better! With the launch of our new site we have SLASHED our prices and upped the offering. Check it out!

10% Discount for ALL Tech Support Guy Members
Simply use the promo code of "T3CHGUY" when ordering to recieve your 10% discount on all shared and reseller hosting packages.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:18 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.