您的位置:首页 > 其它

使用image元素也可以进行表单的提交

2011-08-03 15:39 441 查看
看下面的一段代码,刚开始没有弄明白原理,因为发现下面的form表单,没有我们平时说的input type="submit"这样的提交按钮,也没有javascript中谈到的form.submit绑定在某个点击事件上面,于是卡壳了。但是的确通过图片的提交按钮,的确是可以对该form表单进行提交,莫非....
img也可以对表单进行提交:
<form name="uploadForm" enctype="multipart/form-data" method="post" action="/ajax/designer_handler.php?item_id=<?=$item_id?>&tab=<?=$side?>&is_admin=<?=$is_admin?>" onsubmit="return uploadPhoto();"  style="display:inline"><input type="hidden" name="MAX_FILE_SIZE" value="25000000" style="display:inline;"><input type="hidden" name="uploading" /><?php$u_agent = $_SERVER['HTTP_USER_AGENT'];$btnText = "Browse";if(preg_match('/Chrome/i',$u_agent) || preg_match('/Safari/i',$u_agent)){$btnText = "Choose File";}$fonts_image_path = FontsImage::getImageUrl($design_id, $side);//var_dump($fonts_image_path);?>Upload up to 5 files at once<br />Click the <?= $btnText?> buttons to select files on your computer:<br /><br /><table cellspacing="5"><tr><td height="25">Photo: <input type="file" id="pathname1" name="pathname1" style="width:300px;" accept="image/jpeg" > </td></tr><tr><td height="25">Photo: <input type="file" id="pathname2" name="pathname2" style="width:300px;" accept="image/jpeg" > </td></tr><tr><td height="25">Photo: <input type="file" id="pathname3" name="pathname3" style="width:300px;" accept="image/jpeg" > </td></tr><tr><td height="25">Photo: <input type="file" id="pathname4" name="pathname4" style="width:300px;" accept="image/jpeg" > </td></tr><tr><td height="25">Photo: <input type="file" id="pathname5" name="pathname5" style="width:300px;" accept="image/jpeg" > </td></tr></table><br /><input id="upload_button" type="image" src="/images/personalize/upload.gif" ><img id="upload_button_waiting" src="/images/ajax-loader.gif" style="display:none;" /><br /><span id="upload_message" style="font-style:italic; color:gray; visibility:hidden">Uploading...  (Large pictures may take some time to upload)</span><br /><br /></form>
原来:

表单控件(Form Control):图片提交(input type="image")

input type=image 相当于 input type=submit,不同的是,input type=image 以一个图片作为表单的提交按钮,其中 src 属性表示图片的路径。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐