Welcome Guest, Not a member yet? Register   Sign In
Page with two+ forms - submit on enter not working?
#1

[eluser]smilie[/eluser]
Oke, have strange problem :-)

When you have more then 1 form on the page (using CI form helper) browser will only submit last form on enter key (on keyboard).

So, if users is on the i.e. first form on the page, he fills the data in and hits enter - nothing happens :S

Workaround is to place a form_submit(); button (emtpy works as well) in a hidden <tr> inside that form. But, that's not quite what I like, to make messy code Sad

Is there a 'legitim' work around this problem?

Cheers,
Smilie
#2

[eluser]matt.asbury[/eluser]
Hi Smilie

Have I understood this right? The first form has no submit button unless you place a hidden one which you don't want to do? A form must have a submit button if you want it to submit. I don't think there's anyway around it. You could probably use javascript to submit the form based on which button you press and the element that is currently selected but then if javascript is switched off, you would be left with the same problem.
#3

[eluser]chrisilk[/eluser]
If i understand correctly, 2 forms, 2 submit buttons press enter and always the same form is submitted regardless of which was intended?

does that sound about right?
#4

[eluser]smilie[/eluser]
Hi,

No case is that you _do not_ have to place submit button in form. Default browser behaviour is to automatically submit form on whose element you are at the moment you hit submit. But if there are two or more forms it does not work anymore on CI.

I know how to work around it, but it should work 'out of box'.
#5

[eluser]chrisilk[/eluser]
Do you use chrome developer? or firebug? Perhaps a view source would tell. Something must separate the focus of the 2 forms for the browser to say which to apply the submit action
#6

[eluser]smilie[/eluser]
I have two quite simple forms (don't have code now typing from phone). But both forms are unique with different ids and all input forms are unique across both tables.

I will try tommorow without form_open()

Cheers,
Smilie




Theme © iAndrew 2016 - Forum software by © MyBB