使用javascript&提交表单图像按钮 [英] submitting a form with javascript & image buttons

查看:50
本文介绍了使用javascript&提交表单图像按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有这个应用程序我差不多完成了。

客户要求的唯一内容是能够通过按

输入提交表单。我不认为这会是一个巨大的痛苦屁股和

应用程序将在内部使用所以我不是太担心用户

aren不使用javascript。我正在使用以下javascript来检测

他们是否已经输入:

if(document.layers)

{

document.addEventLister(''onkeypress'',kpress,true);

}

document.onkeypress = kpress;


function kpress(e)

{

if(window.event)

{

//即代码

key = window.event.keyCode;

}

else

{

key = e.which;

}


//用户已按下回车键/退回...让''提交表格

if(key == 13)

{

document.forms [0] .submit();

}

}

这很好用。除了我的

图像按钮之外,它提交的所有输入都很好。我正在使用image_x验证用户是否提交了表格

。由于图像,类型输入不是

提交我无法验证表格。如果我更改图像到

提交我得到一个对象不支持这个属性或方法错误
IE中的
和document.forms [0] .submit不是函数在firefox。


任何人有什么想法吗?

so I have this application I''m nearly finished with. The only thing the
client has requested is the ability to submit the form by pressing
"enter". I didn''t think this would be a huge pain in the ass and the
app will be used internally so I''m not too worried about users who
aren''t using javascript. I''m using the following javascript to detect
whether or not they''ve hit enter:
if(document.layers)
{
document.addEventLister(''onkeypress'', kpress, true);
}
document.onkeypress=kpress;

function kpress(e)
{
if(window.event)
{
//ie code
key = window.event.keyCode;
}
else
{
key = e.which;
}

//user has pressed enter/return...let''s submit the form
if(key == 13)
{
document.forms[0].submit();
}
}
this works fine. It submit all inputs fine...with the exception of my
image buttons. I''m using "image_x" to validate whether or not the form
was submitted by the user. Since "image" type inputs are not being
submitted I can''t validate the form. If I change the "image" to
"submit" I get a "Object doesn''t support this property or method" error
in IE and a "document.forms[0].submit is not a function" in firefox.

anyone have any ideas?

推荐答案

我做了一个快速搜索该小组发现了这个链接:

http://www.faqts.com/knowledge_base/.../fid/129/lang/


不幸的是,它听起来好像没有办法解决这个问题没有

重写一些逻辑。

browntown写道:
I did a quick search of the group and found this link:

http://www.faqts.com/knowledge_base/.../fid/129/lang/

unfortunately, it sounds like there''s no way around this without
rewriting some logic.
browntown wrote:

所以我有这个应用程序我差不多完成了。

客户要求的唯一内容是能够通过按

输入提交表单。我不认为这会是一个巨大的痛苦屁股和

应用程序将在内部使用所以我不是太担心用户

aren不使用javascript。我正在使用以下javascript来检测

他们是否已经输入:


if(document.layers)

{

document.addEventLister(''onkeypress'',kpress,true);

}

document.onkeypress = kpress ;


function kpress(e)

{

if(window.event)

{

//即代码

key = window.event.keyCode;

}

else

{

key = e.which;

}


//用户已按下回车键/返回.. .let'提交表格

if(key == 13)

{

document.forms [0] .submit() ;

}

}


一切正常。除了我的

图像按钮之外,它提交的所有输入都很好。我正在使用image_x验证用户是否提交了表格

。由于图像,类型输入不是

提交我无法验证表格。如果我更改图像到

提交我得到一个对象不支持这个属性或方法错误
IE中的
和document.forms [0] .submit不是函数在Firefox中。


任何人都有任何想法?
so I have this application I''m nearly finished with. The only thing the
client has requested is the ability to submit the form by pressing
"enter". I didn''t think this would be a huge pain in the ass and the
app will be used internally so I''m not too worried about users who
aren''t using javascript. I''m using the following javascript to detect
whether or not they''ve hit enter:
if(document.layers)
{
document.addEventLister(''onkeypress'', kpress, true);
}
document.onkeypress=kpress;

function kpress(e)
{
if(window.event)
{
//ie code
key = window.event.keyCode;
}
else
{
key = e.which;
}

//user has pressed enter/return...let''s submit the form
if(key == 13)
{
document.forms[0].submit();
}
}
this works fine. It submit all inputs fine...with the exception of my
image buttons. I''m using "image_x" to validate whether or not the form
was submitted by the user. Since "image" type inputs are not being
submitted I can''t validate the form. If I change the "image" to
"submit" I get a "Object doesn''t support this property or method" error
in IE and a "document.forms[0].submit is not a function" in firefox.

anyone have any ideas?


browntownaécrit:
browntown a écrit :

所以我有这个应用程序我差不多完了用。

客户要求的唯一内容是能够通过按

输入提交表单。
so I have this application I''m nearly finished with. The only thing the
client has requested is the ability to submit the form by pressing
"enter".



任何浏览器(*)通过触摸输入提交表格。

您只需要:

- 没有几个提交按钮

- 按Enter键时,输入字段必须有焦点。


(*)除了NC4支持这个功能只有在没有多个输入字段的情况下才能获得



问题可能是如果没有到达最后一个字段则避免提交。


一个简单的例子:
http://stephane.moriaux.perso.wanado..._enter_tab.htm

填写第一个字段并通过触摸Enter确认它,这将执行选项卡

,你将进入下一个领域。

点击Enter仍然进入提交按钮并继续回车。


未经IE测试Windows

Any browser(*) submit the form by pressing touch ''Enter''.
You just need :
- not to have several submit button
- when pressing Enter, an imput field must have the focus.

(*) except NC4 which supports this feature
only if there is not more than one input field.

The problem could be to avoid submitting if last field is not reached.

A simple example :
http://stephane.moriaux.perso.wanado..._enter_tab.htm
fill first field and valid it with touch Enter, that will execute tab
and you''ll be in next field.
Hit Enter still to reach submit button and continue with Enter.

Not tested with IE Windows


这样可行。除了我的

图像按钮之外,它提交的所有输入都很好。
this works fine. It submit all inputs fine...with the exception of my
image buttons.



只有一个提交按钮会更好。


我的例子也适用于图像按钮


< input type =" image" SRC =" asm.gif"宽度= QUOT; 50" />


除了IE :-(


药物:


< script type =" text / javascript">

IE = false; / * @ cc_on IE = true; @ * /

< / script>


< input type =" image" src =" asm.gif" width =" 50"

onkeydown =" if(IE)this.form .submit();">

-

Stephane Moriaux et son(moins)vieuxMacdéjàdépassé

Stephane Moriaux和他的(较少)旧Mac已经过时

Only ONE submit button would be better.

My example works too with an image button

<input type="image" src="asm.gif" width="50" />

Except with IE :-(

Medication :

<script type="text/javascript">
IE = false; /*@cc_on IE = true; @*/
</script>

<input type="image" src="asm.gif" width="50"
onkeydown="if(IE) this.form.submit();">
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date




ASM写道:

ASM wrote:

浏览一个écrit:
browntown a écrit :

所以我有这个应用程序我差不多完成了。

客户端要求的唯一的东西是能够通过按

输入提交表格。
so I have this application I''m nearly finished with. The only thing the
client has requested is the ability to submit the form by pressing
"enter".



任何浏览器(*)通过触摸提交表单''输入''。

您只需要:

- 没有多个提交按钮

- 按Enter键时,输入字段必须具有焦点。

(*)除了支持此功能的NC4之外

只有在没有多个输入字段时才能使用。


问题可能是如果没有达到最后一个字段,请避免提交。


一个简单的例子:
http://stephane.moriaux.perso.wanado..._enter_tab.htm

填写第一个字段并对其进行有效触摸输入,将执行标签

,你将进入下一个字段。

点击Enter仍然进入提交按钮并继续回车。


未经IE浏览器测试


Any browser(*) submit the form by pressing touch ''Enter''.
You just need :
- not to have several submit button
- when pressing Enter, an imput field must have the focus.

(*) except NC4 which supports this feature
only if there is not more than one input field.

The problem could be to avoid submitting if last field is not reached.

A simple example :
http://stephane.moriaux.perso.wanado..._enter_tab.htm
fill first field and valid it with touch Enter, that will execute tab
and you''ll be in next field.
Hit Enter still to reach submit button and continue with Enter.

Not tested with IE Windows


此工作正常。除了我的

图像按钮之外,它提交的所有输入都很好。
this works fine. It submit all inputs fine...with the exception of my
image buttons.



只有一个提交按钮会更好。


我的例子也适用于图像按钮


< input type =" image" SRC =" asm.gif"宽度= QUOT; 50" />


除了IE :-(


药物:


< script type =" text / javascript">

IE = false; / * @ cc_on IE = true; @ * /

< / script>


< input type =" image" src =" asm.gif" width =" 50"

onkeydown =" if(IE)this.form .submit();">


-

Stephane Moriaux et son(moins)vieuxMacdéjàdépassé

Stephane Moriaux和他的(较少)旧Mac已经过时


Only ONE submit button would be better.

My example works too with an image button

<input type="image" src="asm.gif" width="50" />

Except with IE :-(

Medication :

<script type="text/javascript">
IE = false; /*@cc_on IE = true; @*/
</script>

<input type="image" src="asm.gif" width="50"
onkeydown="if(IE) this.form.submit();">
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date



不要给提交按钮< ... name =" submit" .... 。

Dont give < ... name="submit".... to the submit button.


这篇关于使用javascript&amp;提交表单图像按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆