当前位置: 代码迷 >> JavaScript >> 试了几种方法,都不行,到底如何判断
  详细解决方案

试了几种方法,都不行,到底如何判断

热度:426   发布时间:2012-06-20 20:37:21.0
试了几种方法,都不行,到底怎么判断
HTML code

<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <meta http-equiv="Pragma" content="no-cache">
      <link rel="stylesheet" href="wancfg_data/stylemain.css" type="text/css">
         <link rel="stylesheet" href="wancfg_data/colors.css" type="text/css">
            <script language="javascript">
<!-- hide

var progress = 0;
if (document.images)
{
  pic1= new Image();
  pic1.src="circle.gif";
}
function isInProgress() {
   var bopregd = '1';
   if ( progress == 0 )  {
      if (bopregd == 1) {
         progress = 1;
         return true;
      } else {
         alert('No BOP registered, could not upgrade BOP firmware.');
         return false;
      }
   }
   alert('Upload frimware is in progress, please wait for a minute.');
   return false;
}

// done hiding -->
</script>
   </head>
   <body>
      <blockquote>
         <form method="post" enctype="multipart/form-data" action="uploadbopfw.cgi" onsubmit="return isInProgress();">
            <b class="gentitle">Management </b><br>
            <br><br>
            <table border="0" cellpadding="0" cellspacing="0">
               <tbody><tr>
                  <td>Firmware file:&nbsp;
                  </td>
                  <td><input name="filename" size="15" type="file"></td>
               </tr>
            </tbody></table>
            <p align="center"><input value="Update Firmware" type="submit"></p>
         </form>
      </blockquote>
   

</body></html>



在没选文件的时候,直接点Update Firmware要提示。
到底怎么实现?

------解决方案--------------------
function isInProgress() {
if(document.getElementsByTagName("input")[0].value==""){
alert("请先选择一个文件");
return false;
}
var bopregd = '1';
if ( progress == 0 ) {
if (bopregd == 1) {
progress = 1;
return true;
} else {
alert('No BOP registered, could not upgrade BOP firmware.');
return false;
}
}
alert('Upload frimware is in progress, please wait for a minute.');
return false;
}
------解决方案--------------------
HTML code

<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <meta http-equiv="Pragma" content="no-cache">
      <link rel="stylesheet" href="wancfg_data/stylemain.css" type="text/css">
         <link rel="stylesheet" href="wancfg_data/colors.css" type="text/css">
            <script language="javascript">
<!-- hide

var progress = 0;
if (document.images)
{
  pic1= new Image();
  pic1.src="circle.gif";
}
function isInProgress() {
if(document.getElementById("myfile").value == ""){alert('a');return false;}  //判断是否上传文件
   var bopregd = '1';
   if ( progress == 0 )  {
      if (bopregd == 1) {
         progress = 1;
         return true;
      } else {
         alert('No BOP registered, could not upgrade BOP firmware.');
         return false;
      }
   }
   alert('Upload frimware is in progress, please wait for a minute.');
   return false;
}

// done hiding -->
</script>
   </head>
   <body>
      <blockquote>
         <form method="post" enctype="multipart/form-data" action="uploadbopfw.cgi" onsubmit="return isInProgress();">
            <b class="gentitle">Management </b><br>
            <br><br>
            <table border="0" cellpadding="0" cellspacing="0">
               <tbody><tr>
                  <td>Firmware file:&nbsp;
                  </td>
                  <td><input name="filename" size="15" type="file" id="myfile"></td>  //加了个ID
               </tr>
            </tbody></table>
            <p align="center"><input value="Update Firmware" type="submit"></p>
         </form>
      </blockquote>
</body></html>
 
  相关解决方案