js 判断文件时候为空


/**
 * 初始化 选择试题列表页面,判断复选框是否选中
 **/
function initBankchoose_list(){
 var ques = $("#questionNo",window.parent.document).val().split(",");
 $(".ck").each(function () {
  for(var i = 0;i<ques.length; i++){
   if($(this).val()==ques[i]){
    $(this).attr("checked",true);
   }
  }
 });
}

function addMore(){

 var td = document.getElementById("more"); 
 var br = document.createElement("br");
 var input = document.createElement("input");
 var button = document.createElement("input");
 
 input.type = "file";
 input.name = "file";
 
 button.type = "button";
 button.value = "删除";
 
 button.onclick = function()
 {
  td.removeChild(br);
  td.removeChild(input);
  td.removeChild(button);
 }
 
 td.appendChild(br);
 td.appendChild(input);
 td.appendChild(button); 
}

 function deleteFileById(path,filePath,fileId,index){
 
   if(confirm('你确定要删除吗?')){
        $.ajax({
    type:"post",
    url:path+"/personcenter/growinfo_ajax/deleteFileById.action", 
    data: 'filePath='+filePath+"&fileId="+fileId,
    dataType: "json",
    async : false,
    cache:false,
    success:function(){
     alert("删除成功!");
     
     $("#divFile"+index).hide(); //隐藏被删除文件的div
     //已上传文件列表数量减一
     $("#uploadedFileCount").val($("#uploadedFileCount").val()-1);
    }
   });
   }
 }
 
 
 function checkGrowUpinfo(){
  
  if($("#studentId").val() == ''){
   alert("请选择学生!");
   return false;
  }
  
  if($("#uploadYear").val() == ''){
   alert("请选择年份!");
   return false;
  }
  
  if($("#semester").val() == ''){
   alert("请选择学期!");
   return false;
  }
  if($("#honorLevelCode").val() == ''){
   alert("请选择荣誉层级!");
   return false;
  }
  
  if($("#title").val() == ''){
   alert("请填写标题!");
   return false;
  }
  
  if(checkFile() == false){
     alert("请选择上传文件!");
     return false;
  }
  
  return true;
 }
  
 // 判断文件列表是否为空
 function checkFile(){
  var uploadedFileCount = $("#uploadedFileCount").val();
  var flagCount = false;
  if(uploadedFileCount > 0){
   flagCount = true;
  }
  
  var file = document.getElementsByName("file");
  var flag = false;
  for(var i =0;i<file.length;i++){
     if(file[i].value != ""){
       flag = true;
       break;
     }
  }
  if(flag == true || flagCount == true){
    return true;
  }else{
    return false;
  }
 }
  
 //打开试题类型对应科目弹出层 
 function showstudentinfo(obj,path){
  var operno = $("#opernoid").val();
  
  /*
   $.ajax({
    type:"post",
    url:path+"/personcenter/growthrecord/listGrowUpinfo.action?flag=1", 
    dataType: "json",
    async : false,
    cache:false,
    success:function(){
     // window.location.reload();
     window.location.href=path+"/personcenter/uploadpaper/listMyExamPaper.action?para=true";
    }
   });
    */
   
    // alert(path+"/personcenter/growinfo/listStudentInfo.action");
    $("#materIframe").attr("src",path+"/personcenter/growinfo/listStudentInfo.action");
   
  openZheZhao();
     var wi=($(window).width()-$("#autoshow").width())/2;
     var he=($(window).height()-$("#autoshow").height())/2;
              
     var ttop=$(obj).offset().top;
     $("#autoshow").css({top:(ttop+20)+"px",left:wi+"px",position:"absolute","z-index":1001}).show();
 
 }

function tidiv(path){
 
 var radioName = materIframe.document.getElementsByName("radioName");
 var operNo = materIframe.document.getElementsByName("frameOperNo");
 var userName = materIframe.document.getElementsByName("frameUserName");
 var gradeClass = materIframe.document.getElementsByName("frameGradeClass"); 
 var flag = true;
 // var Checked=false; 
 for(var i=0;i<radioName.length;i++){
  if(radioName[i].checked){
  // Checked=true;  
   $("#studentId").val(operNo[i].value);
   $("#userName").html(userName[i].value);
   $("#gradeClass").html(gradeClass[i].value);
   flag = false;
            break;
  }
 }
 if(flag){
   alert("请选择学生!");
   return false;
 }
closeShowDiv();
}

function inithonorLevelCode(path){ 

 $.ajax({ 
  type:"post",
  url:path+"/manager/growthrecord_ajax/selHonorLevel.action", 
  dataType: "json",
  async : false,
  cache:false,
  success:function(data){   
   var honorLevelList=data.honorLevelList;
   var length=honorLevelList.length;
   for(var i=0;i<length;i++){
    $("#honorLevelCodeId").append($("<option value='"+honorLevelList[i].honorLevelCode+"'>"+honorLevelList[i].honorLevelName+"</option>"));
   }
  }
  
 }); 
}

function inithonorLevelCodeNo(path){ 

 $.ajax({ 
  type:"post",
  url:path+"/manager/growthrecord_ajax/selHonorLevel.action", 
  dataType: "json",
  async : false,
  cache:false,
  success:function(data){   
   var honorLevelList=data.honorLevelList;
   var length=honorLevelList.length;
   for(var i=0;i<length;i++){
    $("#honorLevelCodeNoId").append($("<option value='"+honorLevelList[i].honorLevelCode+"'>"+honorLevelList[i].honorLevelName+"</option>"));
   }
  }
  
 }); 
}

function closeShowDiv(){
 $("#autoshow").hide();
 closeZheZhao(); 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值