Jump to content


Photo

So, i have a form...


  • Please log in to reply
5 replies to this topic

#1 Xurion

Xurion
  • Members
  • PipPipPip
  • Advanced Member
  • 259 posts

Posted 23 August 2006 - 09:44 AM

I'm trying to make a form that submits when you press the enter/return key. When I have so far is 4 random numbers that display images on a page. The user must input the correct number shown and press the submit button. Done correctly this tells you have have done it right, but it only seems to submit if you click the button, and seems to refresh the page when you press the enter/return key.

If you wana see the example i have uploaded it is it http://www.xurion.co...php/strrchr.php

Thx in advance.

Xur

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 23 August 2006 - 10:16 AM

this is happening because the browser focus is probably on the url bar of your browser, so when you press enter, it's like typing in the url again and pressing enter.  if you press tab, it changes the focus to the next element of the browser, i.e.- the field where you enter in the number, the submit button, etc... you can possibly resolve this with javascript. i'm not sure if you can automatically give a certain element focus right off the bat (like your submit button), but you certainly can't do it with php.  and even if you could, the user could simply press tab or click on a different element and the submit button loses its focus. 

i'm moving this to the javascript forum.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 Xurion

Xurion
  • Members
  • PipPipPip
  • Advanced Member
  • 259 posts

Posted 23 August 2006 - 10:18 AM

*sigh* lol moved twice now...

Anyways, if you type the number and hit enter/return it just refreshes... This does not have the focus in the URL

#4 radalin

radalin
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 23 August 2006 - 11:24 AM

well if the focus is in one of the inputs, when you click on enter it should automaticaly submit the form. You don't need to write extra code for that. If that's a text area things change, but on a simple password or text input enter button submits it. If the submit button is in the from element. Enter should work. At least it works in all of the sites I seen. I just write my username press tab then write my password then press enter :) No extra code is required :)

At least I think of course :)
Roy Simkes
Yet Another Parkyeri Developer

#5 Xurion

Xurion
  • Members
  • PipPipPip
  • Advanced Member
  • 259 posts

Posted 23 August 2006 - 12:36 PM

well if the focus is in one of the inputs, when you click on enter it should automaticaly submit the form. You don't need to write extra code for that. If that's a text area things change, but on a simple password or text input enter button submits it. If the submit button is in the from element. Enter should work. At least it works in all of the sites I seen. I just write my username press tab then write my password then press enter :) No extra code is required :)

At least I think of course :)

This is what I thought. can you have a look at the sources from the link I supplied earlier and see if there is anything wrong... I don't see anything wrong but it would be good to get a second person's opinion.

Thx again

#6 radalin

radalin
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 23 August 2006 - 06:16 PM

Well in my FF the enter works. and I see the correct images thing. It also works in my IE but instead of correct images I see more numbers to enter.

But enter button submit works.
Roy Simkes
Yet Another Parkyeri Developer




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users