0

该功能仅在第一次使用,刷新页面后无法使用。来自网站控制台的错误消息是:

未捕获的 ReferenceError: submit_photo 未定义 AddDeletePhoto.php?exhibit_id=2:1 onclick

Uncaught SyntaxError: Unexpected token ILLEGAL

这是 onlick html:

<a data-role="button" data-theme="b" href=javascript:void(0)" onclick="submit_photo(); return false;">
                  Upload
               </a>

这是JS:

   <script type="text/javascript">
        function submit_photo() {
            alert("test...");
            var allowedfilesize = 1024;
            var photo = document.getElementById('photo');
            var imagefilesize = Math.round(parseInt(photo.files[0].size) / 1024);

            if (imagefilesize > allowedfilesize) {
                photo.value = '';
                document.getElementById('errormessage').innerHTML = 'The file size is ' + imagefilesize + 'kB which is larger than the allowed size of ' + allowedfilesize + 'kB';
            } else {
                alert("uploading...");
                document.getElementById('errormessage').innerHTML = '';
                document.forms['addphoto'].submit();
                return false;
            }
        }
    </script>
4

0 回答 0