Input的type=image和type=submit

根据html标准,input的type=image 的涵义与type=submit相同,只是可以用图片替代提交的按钮。所以type=image直接触发onsubmit 事件。利用图片提交表单有两种方式:

1.<input src=”xxx.gif”>
用这种方式提交会发生表单提交两次的现象,经常会造成表单元素被重复提交,数据库被写入异常!!
原因:HTML 中 image的描述是“创建一个图像控件,该控件单击后将导致表单立即被提交”。
2.<img src=”xxx.gif”>
这种方式提交是正常的没有问题,
所以,请少用第一种方式提交数据尤其是在struts的应用中
注!无论哪种方式提交都在包含在<form>里面。

Leave a comment

Your comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word