⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 refbasic.asp

📁 学生档案与成绩管理(1)学生档案管理:记录每个学生的档案信息
💻 ASP
字号:
<style type="text/css">
	#DummyRefOption {position:absolute;visibility:hidden;left:0;top:0;width:0;height:0;z-index:-1}
</style>    
<!-- #include file = "../include/asphead.asp" -->
<!-- #include file = "../include/function.asp" -->
<%CheckUser()%>
<link href="../include/main.css" rel="stylesheet" type="text/css">
<script src="../include/function.js" type="text/javascript"></script>
<script language="javascript">
<!--

	//Index,1 based,选框项目发生变化
	function OptionChanged(Index)
	{
		var OptionCount;
		var selectedIndex;
		OptionCount=RefOption.length-1;		//注意,需要将那个假的RefOption排除掉
		if(OptionCount!=Index)	//只有选择非底层option才刷新option选项
		{
			selectedIndex=RefOption[Index-1].selectedIndex;
			if(selectedIndex==0)
			{
				//如果未选择任何选项,则将下层的option都置空
				for(var i=Index+1;i<=OptionCount;i++)
				{
					RefOption[i-1].length=0;
				}
			}
			else
			{
				//获取各选项的当前值,刷新本页面
				var curValue,curText;
				for(var i=1;i<=Index;i++)
				{
					selectedIndex=RefOption[i-1].selectedIndex;
					curValue=RefOption[i-1][selectedIndex].value;
					curText=RefOption[i-1][selectedIndex].text;
					if(curValue>0)
						//如果本字段是选择型的,其option item中的value值为itemid
						eval("frmData.curOptionText"+i+".value=curValue;")
					else
						eval("frmData.curOptionText"+i+".value=curText;")
				}
				for(var i=Index+1;i<=5;i++)	//目前最多有5层
				{
					eval("frmData.curOptionText"+i+".value='';")
				}
				btnAdd.disabled =true;
				btnSave.disabled =true;
				document.frmData.RefreshForm.value ="1";
				document.frmData.target ="_self";
				document.frmData.submit();
			}
		}
	}

	function AddRecord() {
		var SheetAndRowID;
		SheetAndRowID=frmData.BaseSheetID.value+JoinChar+0;
		if(window.showModalDialog("viewframe.asp?target=new.asp?SheetAndRowID="+SheetAndRowID, "","dialogwidth:640px;dialogheight:480px;Status:0;center:1;resizable=1;")==true)
		{
			btnAdd.disabled =true;
			btnSave.disabled =true;
			document.frmData.RefreshForm.value ="2";
			document.frmData.target ="_self";
			document.frmData.submit();
		}
	}

	function Save()
	{
		var selectedIndex;
		var InputObj,strValue

		OptionCount=RefOption.length-1;		//注意,需要将那个假的RefOption排除掉
		selectedIndex=RefOption[OptionCount-1].selectedIndex;		//这里加1是由于option本身还有一个空item
		if(selectedIndex<=0)
		{
			alert("未选择有效的记录,请选择。");
			return false;
		}
		strValue=RefOption[OptionCount-1][selectedIndex].text;		//这里加1是由于option本身还有一个空item
		InputObj=GetInputObj(window.dialogArguments[1]);
		if(JTrim(InputObj.value).toLowerCase()==JTrim(strValue).toLowerCase())
			parent.window.returnValue =true;						//有些用户是直接输入然后click小钮的,需要显示引用信息。
		else
			parent.window.returnValue =true;
		InputObj.value=JTrim(strValue);
		window.close(); 
	}
	
	function GetInputObj(obj)
	{
		var IdxForRefObj;
		IdxForRefObj=window.dialogArguments[0];
		return(obj.document.all(IdxForRefObj))
	}

	function Cancel()
	{
		parent.window.returnValue =false;
		window.close(); 
	}

//-->
</SCRIPT>

<%

	dim WExcel
	set WExcel=server.CreateObject("WExcel.Sheet")

	dim SheetID,BaseSheetID,BasicLimit

	dim ActionSource	'此页面的调用来源
	dim IDAndValues,Parts,strRefText
	if Request.Form("RefreshForm")="1" then
		'更改本页面上的option选项,引起页面刷新,IDAndValues取自于form
		ActionSource=2
		IDAndValues=Request.Form("IDAndValues")
	elseif Request.Form("RefreshForm")="2" then
		'从本本页面上直接新增基本表的记录,引起页面刷新,IDAndValues取自于form
		ActionSource=3
		IDAndValues=Request.Form("IDAndValues")
	else
		'从父页面弹出本页面,IDAndValues取自于QueryString
		ActionSource=1
		IDAndValues=Request.QueryString("IDAndValues")
	end if

	'IDAndValues,从父页面传递过来的参数,指定如何选择主表记录,格式:
	'SheetID+JoinChar+BaseSheetID+2个JoinChar+strRefText+3个JoinChar+BasicLimit
	Parts=split(IDAndValues,JoinChar)
	SheetID=Parts(0)
	BaseSheetID=Parts(1)

	dim Pos1,Pos2
	Pos1=instr(1,IDAndValues,JoinChar+JoinChar)
	Pos2=instr(1,IDAndValues,JoinChar+JoinChar+JoinChar)

	strRefText=""
	if Pos1>1 then
		if Pos2>Pos1 then
			strRefText=mid(IDAndValues,Pos1+2,Pos2-Pos1-2)
		else
			strRefText=mid(IDAndValues,Pos1+2)
		end if
	end if

	BasicLimit=""
	if Pos2>0 then
		BasicLimit=mid(IDAndValues,Pos2+3)
	end if


	dim BaseSheetCaption,BaseFieldCaption,strBody,Result

	Result=WExcel.GetRefPage(cint(UserID),cint(ActionSource),cint(SheetID),cint(BaseSheetID),cstr(BasicLimit),cstr(strRefText),BaseSheetCaption,BaseFieldCaption,strBody)
	CheckErr
%>

	<html>
		<head>
			<title><%=BaseSheetCaption%></title>
			<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
		</head>
		<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="overflow-x: hidden">
			<table width="100%" align=center border=0>
				<tr height="35">
					<td colspan=5>
						<b>
							请选择<%=BaseFieldCaption%>
						</b>
					</td>
				</tr>
				<tr height=130 valign="top">
					<td colspan=5>
						<table width="95%" border=0 CELLSPACING="1" CELLPADDING="0">
							<%=strBody%>
						</table>
					</td>
				</tr>
				<tr>
					<td colspan="5">
						<table width="100%">
							<tr>
								<td width="12%"></td>
								<td width="25%"><input id="btnAdd" type="button" value="新增" name="btnAdd" style="cursor:hand; WIDTH: 50px; HEIGHT: 24px" LANGUAGE="javascript" onclick="return AddRecord()"></td>
								<td width="25%"><input id="btnSave" type="button" value="确定" name="btnSave" style="cursor:hand; WIDTH: 50px; HEIGHT: 24px" LANGUAGE="javascript" onclick="return Save('save.asp')"></td>
								<td width="25%"><input id="btnCancel" type="button" value="取消" name="btnCancel" style="cursor:hand; WIDTH: 50px; HEIGHT: 24px" LANGUAGE="javascript" onclick="return Cancel()"></td>
								<td width="12%"></td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			<form METHOD="post" name="frmData">
				<input TYPE="hidden" NAME="BaseSheetID" value="<%=BaseSheetID%>">
				<input TYPE="hidden" NAME="IDAndValues" value="<%=IDAndValues%>">
				<input TYPE="hidden" NAME="curOptionText1">
				<input TYPE="hidden" NAME="curOptionText2">
				<input TYPE="hidden" NAME="curOptionText3">
				<input TYPE="hidden" NAME="curOptionText4">
				<input TYPE="hidden" NAME="curOptionText5">
				<input TYPE="hidden" NAME="RefreshForm">
			</form>
		</body>                                                                                                           
	</html>
	<!--加一个不使用RefOption,目的是让界面上有多个RefOption存在,
		这样javascript就肯定能将RefOption当作数组使用了。
	//-->
	<div id=DummyRefOption>
		<select name=RefOption style="WIDTH: 162px">
		</select> 
	</div>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -