'打开时间区间搜索功能 sub OpenTimeSearchMethod() dim TimeLockStr if window.document.searchform.SearchTime.checked=true then TimeLockStr=false else TimeLockStr=true for i=0 to 2 window.document.searchform.TimeMethod(i).checked=false next ChangeTimeSearch("Close") end if for i=0 to 2 window.document.searchform.TimeMethod(i).disabled=TimeLockStr next end sub '改变时间区间选择方式 sub ChangeTimeSearch(iMethod) dim i dim DateLockStr,MonthLockStr,FreeLockStr select case iMethod case "MethodIsDate" DateLockStr=false MonthLockStr=true FreeLockStr=true window.document.searchform.GetDate.value=0 window.document.searchform.GetMonth.value="--" window.document.searchform.findStartTime.value=Date() window.document.searchform.findEndTime.value=Date() case "MethodIsMonth" DateLockStr=true MonthLockStr=false FreeLockStr=true window.document.searchform.GetDate.value="--" window.document.searchform.GetMonth.value=1 window.document.searchform.findStartTime.value=DateAdd("m",-1,Date()) window.document.searchform.findEndTime.value=Date() case "MethodIsFree" DateLockStr=true MonthLockStr=true FreeLockStr=false window.document.searchform.GetDate.value="--" window.document.searchform.GetMonth.value="--" window.document.searchform.findStartTime.value=Date() window.document.searchform.findEndTime.value=Date() case else DateLockStr=true MonthLockStr=true FreeLockStr=true window.document.searchform.findMethod.value="text" window.document.searchform.GetDate.value="--" window.document.searchform.GetMonth.value="--" window.document.searchform.findStartTime.value="---- -- --" window.document.searchform.findEndTime.value="---- -- --" end select window.document.searchform.GetDate.disabled=DateLockStr for i=0 to 5 window.document.searchform.iDate(i).disabled=DateLockStr next window.document.searchform.GetMonth.disabled=MonthLockStr for i=0 to 5 window.document.searchform.iMonth(i).disabled=MonthLockStr next window.document.searchform.findStartTime.disabled=FreeLockStr window.document.searchform.findEndTime.disabled=FreeLockStr for i=0 to 5 window.document.searchform.iFree(i).disabled=FreeLockStr next end sub '改变开始时间或结束时间 sub ChangeFreeTime() if window.document.searchform.GetDate.disabled=false then if IsNumeric(window.document.searchform.GetDate.value) then window.document.searchform.findEndTime.value=Date() window.document.searchform.findStartTime.value=DateAdd("d",window.document.searchform.GetDate.value * -1 ,window.document.searchform.findEndTime.value) else MsgBox "这里必须是数字!请输入数字。",vbOKonly+vbExclamation,"输入错误" window.document.searchform.GetDate.Focus() window.document.searchform.GetDate.Select() end if end if if window.document.searchform.GetMonth.disabled=false then if IsNumeric(window.document.searchform.GetMonth.value) then window.document.searchform.findEndTime.value=Date() window.document.searchform.findStartTime.value=DateAdd("m",window.document.searchform.GetMonth.value * -1 ,window.document.searchform.findEndTime.value) else MsgBox "这里必须是数字!请输入数字。",vbOKonly+vbExclamation,"输入错误" window.document.searchform.GetMonth.Focus() window.document.searchform.GetMonth.Select() end if end if end sub '通过选择 前 n 天(月) 按钮 来调整时间区间 sub InputTime(iDate) if IsNumeric(iDate) then if window.document.searchform.GetDate.disabled=false then window.document.searchform.GetDate.value=iDate window.document.searchform.findEndTime.value=Date() window.document.searchform.findStartTime.value=DateAdd("d",window.document.searchform.GetDate.value * -1 ,window.document.searchform.findEndTime.value) else window.document.searchform.GetMonth.value=iDate window.document.searchform.findEndTime.value=Date() window.document.searchform.findStartTime.value=DateAdd("m",window.document.searchform.GetMonth.value * -1 ,window.document.searchform.findEndTime.value) end if end if end sub '通过选择 时间区间 按钮 直接改变时间区间 sub InputFreeTime(iDate) if IsNumeric(iDate) then if IsDate(window.document.searchform.findEndTime.value) then select case iDate case 30 window.document.searchform.findStartTime.value=DateAdd("m",-1,window.document.searchform.findEndTime.value) case 60 window.document.searchform.findStartTime.value=DateAdd("m",-2,window.document.searchform.findEndTime.value) case 180 window.document.searchform.findStartTime.value=DateAdd("m",-6,window.document.searchform.findEndTime.value) case else window.document.searchform.findStartTime.value=DateAdd("d",-iDate,window.document.searchform.findEndTime.value) end select else MsgBox "结束日期必须是时间格式!请输入结束日期。" & vbCrLf & " (格式为:yyyy-mm-dd)",vbOKonly+vbExclamation,"输入错误" window.document.searchform.findEndTime.Focus() window.document.searchform.findEndTime.Select() end if end if end sub '检查时间区间选择情况 function CheckTimeMethod() CheckTimeMethod=true if window.document.searchform.TimeMethod(0).checked=true then if not IsNumeric(window.document.searchform.GetDate.value) then MsgBox "这里必须是数字!请输入数字。",vbOKonly+vbExclamation,"输入错误" window.document.searchform.GetDate.Focus() window.document.searchform.GetDate.Select() CheckTimeMethod=false end if end if if window.document.searchform.TimeMethod(1).checked=true then if not IsNumeric(window.document.searchform.GetMonth.value) then MsgBox "这里必须是数字!请输入数字。",vbOKonly+vbExclamation,"输入错误" window.document.searchform.GetMonth.Focus() window.document.searchform.GetMonth.Select() CheckTimeMethod=false end if end if if not IsDate(window.document.searchform.findStartTime.value) then MsgBox "开始必须是时间格式!请重新输入起始时间。" & vbCrLf & " (格式为:yyyy-mm-dd)",vbOKonly+vbExclamation,"输入错误" window.document.searchform.findStartTime.Focus() window.document.searchform.findStartTime.Select() CheckTimeMethod=false elseif not IsDate(window.document.searchform.findEndTime.value) then MsgBox "结束必须是时间格式!请重新输入结束时间。" & vbCrLf & " (格式为:yyyy-mm-dd)",vbOKonly+vbExclamation,"输入错误" window.document.searchform.findEndTime.Focus() window.document.searchform.findEndTime.Select() CheckTimeMethod=false elseif Cdate(window.document.searchform.findEndTime.value) < Cdate(window.document.searchform.findStartTime.value) then TempTime=window.document.searchform.findEndTime.value window.document.searchform.findEndTime.value=window.document.searchform.findStartTime.value window.document.searchform.findStartTime.value=TempTime end if end function function checkform() dim Pass Pass=true if window.document.searchform.SearchTime.checked=true then if window.document.searchform.TimeMethod(0).checked or window.document.searchform.TimeMethod(1).checked or window.document.searchform.TimeMethod(2).checked then if not CheckTimeMethod() then Pass=false else window.document.searchform.findMethod.value="time" window.document.searchform.findStartTime.disabled=false window.document.searchform.findEndTime.disabled=false end if else if trim(window.document.searchform.findText.value)="" then MsgBox "请输入(选择)时间区间或输入搜索关键字!",vbOKonly+vbExclamation,"输入错误" window.document.searchform.findText.Focus() Pass=false else if MsgBox ("您选择了 时间搜索 但没有选择时间区间,要选择时间区间吗?",vbYesNo+vbQuestion,"输入错误")=vbYes then Pass = false end if end if end if else if trim(window.document.searchform.findText.value)="" then MsgBox "请输入搜索关键字!",vbOKonly+vbExclamation,"输入错误" window.document.searchform.findText.value="" window.document.searchform.findText.Focus() window.document.searchform.findText.Select() Pass=false end if end if if Pass then select case window.document.searchform.section.value case "news" window.document.searchform.action="/web2001b/news/search.asp" case "policy" window.document.searchform.action="/web2001b/policy/search.asp" case "forum" window.document.searchform.action="/web2001b/forum/search.asp" case "bbs" window.document.searchform.action="/web2001b/bbs/search.asp" case "adultedu" window.document.searchform.action="/web2001b/adultedu/search.asp" case else Pass=false end select end if checkform=pass end function