日期:2014-05-16  浏览次数:20474 次

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;?
?