提交表单的问题...回车键 [英] Submit Form problem... Enter key
问题描述
我有一个包含几滴列表和文本字段的表单,和一个按钮...
I have a form containing several drop lists and a text field, and a button...
当我按一下按钮,一个ajaxfunction叫...阿贾克斯然后调用一个PHP函数,它从一个MySQL数据库得到的结果......
When I click the button, an ajaxfunction is called... the ajax then calls a php function which gets results from a mysql db...
问题是,我不能做同样的事情,只需打的形式进入,页面只是被刷新......
The problem is that I cant do the same thing by just hitting enter in the form, the page just gets refreshed...
这说明,我认为形式被提交,但忽略ajaxfunction按下回车键的时候,即使我有的onsubmit =AjaxFunction();的形式标记...
That explained, I think the form gets submitted, but ignores the ajaxfunction when hitting enter, EVEN though i have " onSubmit="AjaxFunction();" in the form tag...
任何想法?
有谁知道一个办法忽略的形式提交按下回车键的时候?也许,而不是按一下按钮按下回车键的时候?
Does anybody know a way to ignore the form submit when hitting enter? and maybe instead click the button when hitting enter?
谢谢...
推荐答案
改变你的onsubmit到的onsubmit =返回AjaxFunction();并返回false从AjaxFunction。这将prevent的形式从submiting。
change your onsubmit to onsubmit="return AjaxFunction();" and return false from your AjaxFunction. That will prevent the form from submiting.
这篇关于提交表单的问题...回车键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!