多个附件添加的script角本


<script language="vbscript">
 function xzfj()
  dim count_obj,tr_obj,td_obj,file_obj,form_obj,count,table_obj
  dim button_obj,countview_obj
  dim str1,str2
 
  set form_obj=document.getElementById("form_add")
  'set table_obj=document.getElementById("tbody_fj")
  set fj_obj=document.getElementById("td_fj")
 
  if fj_obj.innertext="无附件" then
     fj_obj.innertext=""
  end if
  set count_obj=document.getElementById("count_obj")
 
  if (count_obj is nothing) then
    set count_obj=document.createElement("input")
        count_obj.type="hidden"
        count_obj.id="count_obj"
        count_obj.value=1
      
        form_obj.appendChild(count_obj)
        count=1
        count_obj.value=1
  else
    set count_obj=document.getElementById("count_obj")
      
        count=cint(count_obj.value)+1
        count_obj.value=count
  end if
 
 
 
 
 
 
  'set tr_obj=document.createElement("TR")
   '   tr_obj.id="tr_"&cstr(count)
    '  table_obj.appendchild(tr_obj)
  'set td_obj=document.createElement("TD")
   '   td_obj.id="td_"&cstr(count)
    '  td_obj.classname="left"
     ' tr_obj.appendchild(td_obj)
      'td_obj.innertext="附件"   
 
  'set td_obj=document.createElement("TD")
   '   td_obj.id="td_"&cstr(count)
     
    '  td_obj.classname="row"
     ' tr_obj.appendchild(td_obj)
     set div_obj=document.createElement("div")
     div_obj.id="div_"&cstr(count)
     div_obj.align="center"
     
      fj_obj.appendchild(div_obj)
   
   str1="附件名称:<input   type='file' name='fj"&count&"' size=55 class='input' id=fj'"&count&"'>"
   str2="<br>附件说明:<input   type='text' name='fjsm"&count&"' class='input' size=55 maxlength=255 id='fjsm"&count&"'>"
   str3="<input type='button' class='button' value='删除本条' onclick='vbscript:delthis("+""""+div_obj.id+""""+")'>"      
   div_obj.innerHtml=str1+str2+str3 
   'alert(str1+str2+str3)
   'alert(div_obj.id)
 
  'set file_obj=document.createElement("input")
   '   file_obj.type="file"
   '   file_obj.classname="input"
    '  file_obj.id="file_"&cstr(count)
     ' td_obj.appendchild(file_obj)
     
  'set button_obj=document.createElement("input")
   '   button_obj.type="button"
    '  button_obj.classname="input"
     ' button_obj.value="删除"
      'button_obj.id="_"&cstr(count)
      'alert("call delthis("+""""+tr_obj.id+""""+")")
      'button_obj.onclick="'"+"vbscript: delthis("+""""+tr_obj.id+""""+")"+"'"
      'td_obj.appendchild(button_obj)
 
     

end function

function delthis(id)

dim child,parent

set child_t=document.getElementById(id)

if  (child_t is nothing ) then
 alert("对象为空")
else

'child_t.removeNode(true)
call delmain_wer(child_t)

end if

set parent=document.getElementById("td_fj")
if parent.hasChildNodes() =false then
   parent.innerText=""
end if
  


end function

 function delmain_wer(obj)
   
   dim length,i,tt
   set tt=document.getElementById("table_obj")
  
   if (obj.haschildNodes) then
    
     length=obj.childNodes.length
     for i=(length-1) to 0 step -1
        
         call delmain_wer(obj.childNodes(i))       
    
         if obj.childNodes.length=0 then
      
            obj.removeNode(false)   
         end if
   
     next
   
   else
   obj.removeNode(false)
   end if
  
  end function

function fun_xzry()
  dim svalue,svalue1
  svalue = popdialog("../share/pop_xzry.asp","300px","300px")
  if svalue <> "" then
    
     svalue1 = Split(svalue,vbTab)
        if form_add.sqr.value<>svalue1(0) then
           form_add.sqr.value = svalue1(0)
           form_add.sqrxm.value = svalue1(1)&"["&svalue1(3)&"]"
           form_add.sqbm.value = "" 
           form_add.sqzw.value = ""
        form_add.sqzwmc.value = ""
           call fun_xzzw
        end if
  end if
end function

'选择职务
 function fun_xzzw()
  dim svalue,sygbh,svalue1
  if form_add.sqr.value <> "" then
   sygbh = form_add.sqr.value 
   svalue = popdialog("../share/pop_xzzw.asp?ygbh=" & sygbh,"300px","300px")
   'msgbox svalue
   if  svalue<> ""then 
       svalue1 = Split(svalue,vbTab)
       form_add.sqzw.value = svalue1(0)
      form_add.sqzwmc.value = svalue1(1) & "[" & svalue1(3) & "]"
      form_add.sqbm.value = svalue1(2)
   end if
  end if
 end function


'提交检测函数
function checktj_atth()
  
  if form_add.sqbm.value="" then
     msgbox("请选择申请部门")
     call fun_xzzw
     exit function
  end if
 
  if form_add.sqzw.value="" then
     msgbox("请选择申请人职位")
     call fun_xzzw
     exit function
  end if
 
  if form_add.sqr.value="" then
     msgbox("请选择申请人")
     form_add.sqr.focus
     exit function
  end if
 
 
 
  if trim(form_add.sqsy.value)="" then
     msgbox("请输入申请事由")
     form_add.sqsy.focus
     exit function
  end if
 
  if len(trim(form_add.sqsy.value))>255 then
     msgbox("申请事由不能超过255个字")
     form_add.sqsy.focus
     exit function
  end if
 
 
 
 
 
  if trim(form_add.yclj.value)="" then
     msgbox("请输入用车路径")
     form_add.yclj.focus
     exit function
  end if
 
  if len(trim(form_add.yclj.value))>255 then
     msgbox("用车路径不能超过255个字")
     form_add.yclj.focus
     exit function
  end if
 
  if trim(form_add.qssj.value)="" then
     msgbox("请填入起始时间")
     form_add.qssj.focus
     exit function
  end if
 
  if trim(form_add.qssj.value)<>"" then
     if isdate(form_add.qssj.value)=false then
        msgbox("请输入标准格式的日期时间")
        form_add.qssj.focus
        exit function
     end if
    
     if instr(1,form_add.qssj.value,"-")=0 then
        msgbox("请填入日期")
        form_add.qssj.focus
        exit function
     end if
  end if
 
  if trim(form_add.jzsj.value)="" then
    
    i=msgbox("截止时间不能为空,默认截止时间为起始时间后一天,按“确定”继续提交",1)
    if i=1 then
       qssj=form_add.qssj.value
        jzsj=dateadd("d",1,qssj)
            form_add.jzsj.value=jzsj
    elseif i=2 then
            form_add.jzsj.focus
           exit function
    end if
  end if
 
 
  if trim(form_add.jzsj.value)<>"" then
     if isdate(form_add.jzsj.value)=false then
        msgbox("请输入标准格式的日期时间")
        form_add.jzsj.focus
        exit function
     end if
    
     if instr(1,form_add.jzsj.value,"-")=0 then
        msgbox("请填入日期")
        form_add.jzsj.focus
        exit function
     end if
  end if
 
  if trim(form_add.qssj.value)<>"" and trim(form_add.jzsj.value)<>"" then
     if cdate(form_add.qssj.value)>cdate(form_add.jzsj.value) then
        msgbox("起始时间不能大于截止时间")
        form_add.jzsj.focus
        exit function
     end if
 
  end if
 
  if trim(form_add.ccrs.value)<>"" then
     if isnumeric(form_add.ccrs.value)=false then
     msgbox("请填入数字乘车人数")
     form_add.ccrs.focus
     exit function
     end if
    
     if instr(1,form_add.ccrs.value,",")>0 or instr(1,form_add.ccrs.value,".")>0 or instr(1,form_add.ccrs.value,"-")>0 then
     msgbox("请填入数字乘车人数")
     form_add.ccrs.focus
     exit function
     end if
 
 
  end if
 
  dim file_obj,i,j '附件检测
 
 
   i=form_add.elements.length
   if (i<>0) then
     for j=0 to i-1
       dim e
       set e=form_add.elements(j)
       if e.type="file" then
         if trim(e.value)="" then
           alert("请选择附件")
           e.focus
           exit function
         end if
       end if
    
     next 

  end if
 
  dim strsplj
 
  strsplj= popdialog("../share/pop_xzsplj.asp?sqzw=" & form_add.sqzw.value & "&sqbm=" & form_add.sqbm.value & "&sqlb=20","300px","300px")
 
  if trim(strsplj)="none" then 
  msgbox "该申请单没有选择相对应的审批流程,无法提交!",vbExclamation,"提示"
  exit function
 elseif trim(strsplj)="noall" then 
  msgbox "没有为当前申请设置任何对应的审批流程,无法提交!您可以尝试选择其他的申请人或申请职位后再提交。",vbExclamation,"提示"
  exit function
    elseif  trim(strsplj)="" or isnull(strsplj) then
  msgbox "寻找当前申请对应的审批流程时碰到错误,建议重新新增申请。",vbExclamation,"提示"
  exit function 
 else
  form_add.splc.value = strsplj
  'msgbox(strsplj)
  
  form_add.encoding = "multipart/form-data"
  form_add.action="clgl_ycsq_addsave.asp"
        form_add.submit
 end if
 
 
end function

</script>


 <table width=500   >
    <form name="form_add" id="form_add" method="post">
     <input type=hidden name="splc">
          <tr>          
            <td   nowrap   id="td_fj"></td>
         </tr>                    
 </table>
 
 
 <div align="center">
   <input name="附件" type="button" id="button_fj"  onClick="vbscript:xzfj()" value="附件" LANGUAGE=javascript>
 </div>
 

 

posted @ 2006-03-17 12:26  Winner.Net(2007)  阅读(801)  评论(0编辑  收藏  举报