Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to go to next input form after hitting ENTER-key 1

Status
Not open for further replies.

aas1611

Programmer
Dec 14, 2001
184
DE
Hello,

I'm developing a bunch of text forms for data entry. I have a problem with the Enter-key. When I'm filling out an input form and press enter, it goes to the submit button, which, like predicted, inserts the data into the database, even though I haven't finished yet.

This is kind of disturbing, because it is very tempting to hit enter after each input form (I'm sure that my user will do that!)

I want that, it goes to the next input form, not to submit button or just disable the enter key, everytime we hit enter.

Any clue anyone? Thanks!
 
While this question has nothing to do with PHP, let me give you an answer, since there's not much to say.

If you have a form with action attribute filled out, enter will behave in that way -- it will submit the form. That is normal behaviour of web forms and it is not good to tamper with default behaviour. If you want, you could capture enter key and then do what you want enter to do with javascript. That still won't work for people with javascript turned off and might annoy people how are used to web forms and submitting them via enter key. If it is a controlled environment, I would consider the JS solution, if not, I would just leave it. If you decide to pursue js, try asking in js forum (forum216).
 
Oh, I thought I could do this thing with PHP. I know that submitting form with enter is a normal behaviour of web forms, but I was just wondering if I could change that with PHP.

Here is something to do with PHP (and HTML):
I tried to retrieve information that has been saved with <textarea> into the database. But this information doesn't appear when I use this code:
Code:
<tr>
<td>Note:</td>
<td><textarea rows="5" cols="50" name="note" value = "<? echo $row->note; ?>"></textarea></td>
</tr>

Is there something wrong my code or any other way to do this?
 
Textarea contents are not stored in value attribute but rather in between the tags. Do this:
Code:
<tr>
  <td>Note:</td>
  <td><textarea rows="5" cols="50" name="note"><? echo $row->note; ?></textarea></td>
</tr>
 
Thanks for the hint and the code. It really helped solving my problem!
 
but if you come over to the javascript forum (forum216) i can give you some code that i have already developed a few months back that does exactly what you want.

it may prove useful to you.

*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
beware of active imagination: [URL unfurl="true"]http://www.coryarthus.com/[/url]

BillyRayPreachersSonIsTheLeetestHax0rDude
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top