Home > Backend Development > PHP Tutorial > 加入判断语句后上传按钮失效

加入判断语句后上传按钮失效

WBOY
Release: 2016-06-20 12:48:40
Original
854 people have browsed it

<form id="upload_form" enctype="multipart/form-data" method="post" action="upload.php" ><input id="img" name="img" type="file" accept="image/*" onChange="fileSelected()" ><input id="img" name="img2" type="file" accept="image/*" onChange="fileSelected()" ><input type="button" value="上传" id="send" onClick="startUploading()" /></form><script>var send=document.getElementById("send");    send.onclick=function() {     var file=document.getElementById("img").value;     var file=document.getElementById("img2").value;         if (file.length<1) {            alert('请选择图片');			return false;             }           }</script>	
Copy after login


回复讨论(解决方案)

<script> <br /> var send=document.getElementById("send"); <br /> send.onclick=function() { <br /> var file=document.getElementById("img").value; <br /> var file=document.getElementById("img2").value; <br /> if (file.length<1) { <br /> alert('请选择图片'); <br /> return false; <br /> } <br /> } <br /> </script>   

加入这个后就失效了。请问大家是怎么回事。

<script> <br /> var send=document.getElementById("send"); <br /> send.onclick=function() { <br /> var file=document.getElementById("img").value; <br /> var file=document.getElementById("img2").value; <br /> if (file.length<1) { <br /> alert('请选择图片'); <br /> return false; <br /> } <br /> return true; <br /> } <br /> </script>   

<script> <br /> var send=document.getElementById("send"); <br /> send.onclick=function() { <br /> var file=document.getElementById("img").value; <br /> var file=document.getElementById("img2").value; <br /> if (file.length<1) { <br /> alert('请选择图片'); <br /> return false; <br /> } <br /> return true; <br /> } <br /> </script>   


不行的

失效了是什么意思? 是指不能提交吗?


先把这个改正再说

失效了是什么意思? 是指不能提交吗?



是的,不能提交。不过现在已搞定了。谢谢!
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template