如何解决:当我从一个下拉列表框中选择一个人名时,然后其下面的文本框跟着变为其人的个人简历(个人简历是从数据库中取得的,这个我可以解决。),之后,我点击提交按钮时,它将人名信息提交到数据库中。我这要求在asp中实现的。请各位大侠帮忙,当然也可以介绍个网站来认识一个,或有累同的信息的。一定加分。
8 个解决方案
#1
一个例子
function ch(selectedids,n)
{
var selectedvalue=selectedids
var i
var t=0
document.form1.s2.length=0
for(i=0;i<n;i++)
{
if(subcat[i][0]==selectedvalue)
{
document.form1.s2.options[t]=new Option(subcat[i][1],subcat[i][2])
t=t+1
}
}
}
function check()
{
if (document.form1.s1.options.selectedIndex==0)
{
alert("请先选择类别")
document.form1.s1.focus()
return false
}
return true
}
/* function beginT(){
var t=window.showModalDialog("../calendar/calendar.htm",null,"dialogWidth:208px;dialogHeight:240px;status:no;help:no");
if (t!=null){
document.form1.T_in.value=t;
}
return;
}*/
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="780" border="0" cellspacing="0" cellpadding="0" height="38%" bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr>
<td width="81%" height="478" valign="top">
<form name="form1" method="post" action="do_mod.asp" onsubmit="return datacheck()">
<table width="100%" border="0">
<tr bgcolor="#E6E0FE">
<td width="12%" align="center">
物品类别
</td>
<td colspan="6">
<script language="javascript">
var subcat=new Array()
<%dim n
n=0
set rs=server.CreateObject("adodb.recordset")
rs.ActiveConnection=conn
rs.Source="select a.T_catid,a.T_name as xx ,a.T_id from cos_T_manage a join cos_T_catagery b on a.T_catid=b.T_id"
rs.CursorType=1
rs.LockType=1
rs.Open
do while not rs.EOF%>
subcat[<%=n%>]=new Array("<%=rs("T_catid")%>","<%=rs("xx")%>","<%=rs("T_id")%>")
<%n=n+1
rs.movenext
loop%>
</script>
<select name="s1" onchange="ch(this.options[this.selectedIndex].value,<%=n%>)">
<option value="0">--请选择--</option>
<%set rsd=server.CreateObject("adodb.recordset")
rsd.ActiveConnection=conn
rsd.Source="select T_id,T_name from cos_t_catagery"
rsd.Open
do while not rsd.EOF
%>
<option value="<%=rsd("T_id")%>">
<%=rsd("T_name")%>
</option>
<%rsd.MoveNext
loop
%>
</select>
</td>
</tr>
<tr bgcolor="#E6E0FE"><td width="12%" align="center">
物品名称
</td>
<td colspan="6">
<select name="s2" onclick="check()"> </select>
</td>
function ch(selectedids,n)
{
var selectedvalue=selectedids
var i
var t=0
document.form1.s2.length=0
for(i=0;i<n;i++)
{
if(subcat[i][0]==selectedvalue)
{
document.form1.s2.options[t]=new Option(subcat[i][1],subcat[i][2])
t=t+1
}
}
}
function check()
{
if (document.form1.s1.options.selectedIndex==0)
{
alert("请先选择类别")
document.form1.s1.focus()
return false
}
return true
}
/* function beginT(){
var t=window.showModalDialog("../calendar/calendar.htm",null,"dialogWidth:208px;dialogHeight:240px;status:no;help:no");
if (t!=null){
document.form1.T_in.value=t;
}
return;
}*/
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="780" border="0" cellspacing="0" cellpadding="0" height="38%" bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr>
<td width="81%" height="478" valign="top">
<form name="form1" method="post" action="do_mod.asp" onsubmit="return datacheck()">
<table width="100%" border="0">
<tr bgcolor="#E6E0FE">
<td width="12%" align="center">
物品类别
</td>
<td colspan="6">
<script language="javascript">
var subcat=new Array()
<%dim n
n=0
set rs=server.CreateObject("adodb.recordset")
rs.ActiveConnection=conn
rs.Source="select a.T_catid,a.T_name as xx ,a.T_id from cos_T_manage a join cos_T_catagery b on a.T_catid=b.T_id"
rs.CursorType=1
rs.LockType=1
rs.Open
do while not rs.EOF%>
subcat[<%=n%>]=new Array("<%=rs("T_catid")%>","<%=rs("xx")%>","<%=rs("T_id")%>")
<%n=n+1
rs.movenext
loop%>
</script>
<select name="s1" onchange="ch(this.options[this.selectedIndex].value,<%=n%>)">
<option value="0">--请选择--</option>
<%set rsd=server.CreateObject("adodb.recordset")
rsd.ActiveConnection=conn
rsd.Source="select T_id,T_name from cos_t_catagery"
rsd.Open
do while not rsd.EOF
%>
<option value="<%=rsd("T_id")%>">
<%=rsd("T_name")%>
</option>
<%rsd.MoveNext
loop
%>
</select>
</td>
</tr>
<tr bgcolor="#E6E0FE"><td width="12%" align="center">
物品名称
</td>
<td colspan="6">
<select name="s2" onclick="check()"> </select>
</td>
#2
<!-- #include file="../../../../../include/OpenConnection.asp" -->
<!--#include file="../../../../../include/adovbs.inc"-->
<%
function OutPutTemptype()
dim oRs,sSql
Set oRs=Server.CreateObject("ADODB.RecordSet")
sSql="select * from T_OA_DocType where gwlbyxbz=1"
oRs.Open sSql,cn,2,3
while Not oRs.EOF
Response.Write "<option value='"&oRs("gwlbid")&"'>"&oRs("gwlbmc")&"</option>"
oRs.MoveNext
wend
oRs.Close
Set oRs=Nothing
end function
%>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<link rel="stylesheet" href="../../../../../csslib/fwstyle.css" type="text/css">
<Script language = "javaScript" src = "../../../../../include/MSAlert.js"></Script>
<script language="vbscript" src="../../../../../include/LimitInput.vbs"></script>
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>选择公文模板</title>
<script language="javascript">
/*=======================================================================
函数名称:GetTemplate()
功能:取得本类型所有得公文模板列表
参数:DocTypeID 模板类型内码
返回:
作者:柯依策
=========================================================================*/
function GetTemplate(DocTypeID){
var xmlDoc,xmlHttp
xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
var oRoot=xmlDoc.createElement("Root")
var oTypeID=xmlDoc.createElement("TypeID")
oTypeID.text=DocTypeID
oRoot.appendChild(oTypeID)
xmlDoc.appendChild(oRoot)
xmlHttp.open("POST","include/DataTemplate.asp?flag=1",false)
xmlHttp.send(xmlDoc)
if(xmlHttp.readyState==4) {
var ErrNumber=xmlHttp.getResponseHeader("Error")
if(ErrNumber!=""){
MWalert(1,"系统出错,等会在操作!")
}
else{
xmlDoc.loadXML(xmlHttp.responseBody) //返回xml文档
var oNodeList=xmlDoc.selectNodes("//Record")
form1.selDocTemplate.length=0
for(var i=0;i<oNodeList.length;i++){
var oOption=document.createElement("Option")
var sValue=oNodeList(i).selectSingleNode("TempFile").text
var sText=oNodeList(i).selectSingleNode("TempName").text
oOption.value=sValue
oOption.text=sText
form1.selDocTemplate.add(oOption)
}
}
}
}
/*=============================================================================
===============================================================================*/
function InitDoc(){
var sDefTypeID=form1.selDocType.value
if(sDefTypeID==""){
return false
}
GetTemplate(sDefTypeID)
}
function DocTypeChange(){
var TypeID=form1.selDocType.value
GetTemplate(TypeID)
}
function SaveClick(){
window.returnValue=form1.selDocTemplate.value
window.close()
}
function CancelClick(){
window.returnValue=""
window.close()
}
function PreviewClick(){
var FileName=form1.selDocTemplate.value
if(FileName==""){
MWalert(1,"请选择公文模板!")
return false;
}
var sPath="../../../../../OAflow/DocuTemplate/textDoc.asp?FileName=" + FileName
try{
varibles=showModalDialog(sPath,"","dialogHeight:550px; dialogWidth:750px; help: No;status: No; ")
}
catch(e){
}
}
</script>
</head>
<body bgcolor="#8CBEF7" topmargin=0 leftmargin=0 onload="InitDoc()" onunload="">
<form method="post" name="form1" action="">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="140">
<tr>
<td width="100%" height="33" align="center" colspan="2"><b>
<font size="3">公文模板库</font></b></td>
</tr>
<tr>
<td width="50%" height="39" align="right">模板类型:</td>
<td width="50%" height="39">
<select size="1" name="selDocType" style="width:200" class="selOA" onchange="DocTypeChange()">
<%OutPutTemptype()%>
</select></td>
</tr>
<tr>
<td width="50%" height="39" align="right">模板列表:</td>
<td width="50%" height="39">
<select size="1" name="selDocTemplate" style="width:200" class="selOA"></select></td>
</tr>
<tr>
<td width="100%" height="52" colspan="2">
<p align="center">
<input type="button" value="预览" name="btPreview" class="btnStandard" onclick="PreviewClick()">
<input type="button" value="确定" name="btSave" class="btnStandard" onclick="SaveClick()">
<input type="button" value="取消" name="btCancel" class="btnStandard" onclick="CancelClick()">
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
<!--#include file="../../../../../include/adovbs.inc"-->
<%
function OutPutTemptype()
dim oRs,sSql
Set oRs=Server.CreateObject("ADODB.RecordSet")
sSql="select * from T_OA_DocType where gwlbyxbz=1"
oRs.Open sSql,cn,2,3
while Not oRs.EOF
Response.Write "<option value='"&oRs("gwlbid")&"'>"&oRs("gwlbmc")&"</option>"
oRs.MoveNext
wend
oRs.Close
Set oRs=Nothing
end function
%>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<link rel="stylesheet" href="../../../../../csslib/fwstyle.css" type="text/css">
<Script language = "javaScript" src = "../../../../../include/MSAlert.js"></Script>
<script language="vbscript" src="../../../../../include/LimitInput.vbs"></script>
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>选择公文模板</title>
<script language="javascript">
/*=======================================================================
函数名称:GetTemplate()
功能:取得本类型所有得公文模板列表
参数:DocTypeID 模板类型内码
返回:
作者:柯依策
=========================================================================*/
function GetTemplate(DocTypeID){
var xmlDoc,xmlHttp
xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
var oRoot=xmlDoc.createElement("Root")
var oTypeID=xmlDoc.createElement("TypeID")
oTypeID.text=DocTypeID
oRoot.appendChild(oTypeID)
xmlDoc.appendChild(oRoot)
xmlHttp.open("POST","include/DataTemplate.asp?flag=1",false)
xmlHttp.send(xmlDoc)
if(xmlHttp.readyState==4) {
var ErrNumber=xmlHttp.getResponseHeader("Error")
if(ErrNumber!=""){
MWalert(1,"系统出错,等会在操作!")
}
else{
xmlDoc.loadXML(xmlHttp.responseBody) //返回xml文档
var oNodeList=xmlDoc.selectNodes("//Record")
form1.selDocTemplate.length=0
for(var i=0;i<oNodeList.length;i++){
var oOption=document.createElement("Option")
var sValue=oNodeList(i).selectSingleNode("TempFile").text
var sText=oNodeList(i).selectSingleNode("TempName").text
oOption.value=sValue
oOption.text=sText
form1.selDocTemplate.add(oOption)
}
}
}
}
/*=============================================================================
===============================================================================*/
function InitDoc(){
var sDefTypeID=form1.selDocType.value
if(sDefTypeID==""){
return false
}
GetTemplate(sDefTypeID)
}
function DocTypeChange(){
var TypeID=form1.selDocType.value
GetTemplate(TypeID)
}
function SaveClick(){
window.returnValue=form1.selDocTemplate.value
window.close()
}
function CancelClick(){
window.returnValue=""
window.close()
}
function PreviewClick(){
var FileName=form1.selDocTemplate.value
if(FileName==""){
MWalert(1,"请选择公文模板!")
return false;
}
var sPath="../../../../../OAflow/DocuTemplate/textDoc.asp?FileName=" + FileName
try{
varibles=showModalDialog(sPath,"","dialogHeight:550px; dialogWidth:750px; help: No;status: No; ")
}
catch(e){
}
}
</script>
</head>
<body bgcolor="#8CBEF7" topmargin=0 leftmargin=0 onload="InitDoc()" onunload="">
<form method="post" name="form1" action="">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="140">
<tr>
<td width="100%" height="33" align="center" colspan="2"><b>
<font size="3">公文模板库</font></b></td>
</tr>
<tr>
<td width="50%" height="39" align="right">模板类型:</td>
<td width="50%" height="39">
<select size="1" name="selDocType" style="width:200" class="selOA" onchange="DocTypeChange()">
<%OutPutTemptype()%>
</select></td>
</tr>
<tr>
<td width="50%" height="39" align="right">模板列表:</td>
<td width="50%" height="39">
<select size="1" name="selDocTemplate" style="width:200" class="selOA"></select></td>
</tr>
<tr>
<td width="100%" height="52" colspan="2">
<p align="center">
<input type="button" value="预览" name="btPreview" class="btnStandard" onclick="PreviewClick()">
<input type="button" value="确定" name="btSave" class="btnStandard" onclick="SaveClick()">
<input type="button" value="取消" name="btCancel" class="btnStandard" onclick="CancelClick()">
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
#3
//后台数据 datatemplate.asp
<!-- #include file="../../../../../../include/OpenConnection.asp" -->
<!-- #include file="../../../../../../include/DBErrorhandle.asp" -->
<%
dim Flag
Flag=Request.QueryString("Flag")
Response.ContentType="text/xml"
'Set 'xmlDoc =Server.CreateObject("Msxml2.DOMDocument.4.0")
Set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async= false
xmlDoc.load Request
'==============================================================
'函数名称:GetTemplate()
'功能:取得指定类型中得所有模板
'作者:柯依策
'日期:2002年10月16日
'===============================================================
function GetTemplate()
set oRoot=xmlDoc.documentElement
dim oRs,sSql
dim nDocTypeID
nDocTypeID=oRoot.selectSingleNode("TypeID").text
if nDocTypeID="" then
vHaveError()
end if
on Error resume Next
Set oRs=Server.CreateObject("ADODB.RecordSet")
sSql="select * from T_OA_DocTemplate where gwlbid="&nDocTypeID
oRs.Open sSql,cn,2,3
if oRs.EOF=false then
Set oRecords=xmlDoc.createElement("Records")
while Not oRs.EOF
Set oRecord=xmlDoc.createElement("Record")
Set oTempName=xmlDoc.createElement("TempName")
oTempName.text=oRs("gwmbmc")
Set oTempFile=xmlDoc.createElement("TempFile")
oTempFile.text=oRs("gwmblj")
oRecord.appendChild oTempName
oRecord.appendChild oTempFile
oRecords.appendChild oRecord
oRs.MoveNext
wend
oRoot.appendChild oRecords
end if
if Err.number>0 then
vHaveError()
else
Response.CharSet="UTF-8"
Response.ContentType="text/xml"
Response.BinaryWrite xmlDoc.xml
end if
end function
'========================================================
'函数名称:CreateDoc()
'功能:创建word文档
'返回:
'作者:柯依策
'日期:2002年10月16日
'版本:01
'=========================================================
function CreateDoc()
set oRoot=xmlDoc.documentElement
dim sDocID,sOldFile,sNewFile
sDocID=oRoot.selectSingleNode("DocID").text
sOldFile=oRoot.selectSingleNode("OldFile").text
sNewFile=oRoot.selectSingleNode("NewFile").text
if sDocID="" or sOldFile="" or sNewFile="" then
vHaveError()
end if
on Error Resume next
dim sPath,sSPath,sDPath,sDTextName
dim oSfo,oSFile,oDFile
sPath=Server.MapPath("../../../../../../OAFlow/DocuTemplate/tempDoc")
sSPath=sPath & "\" & sNewFile
'Response.Write sSPath
'目标文件信息
sDTextName="text" & right(sNewFile,len(sNewFile)-4)
sDPath=Server.MapPath("../../../../../../OAFlow/DocuTemplate/textDoc") & "\" & sDTextName
set oSfo=Server.CreateObject("Scripting.FileSystemObject")
set oSFile=oSfo.GetFile(sSPath)
oSFile.Copy sDPath
if Err.number>0 then
vHaveError()
else
sDName=sDTextName
SaveDoc sDName,sDocID
Response.AddHeader "Flag", 1
end if
end function
function SaveDoc(FileName,gwid)
on Error resume Next
dim oRs,sSql
sSql="select * from T_OA_DocText where gwid="&gwid
Set oRs=Server.CreateObject("ADODB.RecordSet")
oRs.open sSql,cn,2,3
oRs("gwzwlj")=FileName
oRs("gwid")=gwid
oRs.update
oRs.close
Set oRs=Nothing
if Err.number>0 then
vHaveError()
end if
end function
'====================================================================
'函数vHaveError() 错误处理,现在暂时是 ,如果Err.nubmer<>0 就
'在头文件输出Error=1,表示有错误,停止程序的执行。
'作者:柯依策
'时间:2002年8月30日
'====================================================================
Function vHaveError()
dim sError
'错误的描述
if Err.number<>0 then
Response.AddHeader "Error",1
Response.End
end if
End Function
Select Case Flag
Case 1
GetTemplate
case 2
CreateDoc
End Select
%>
<!-- #include file="../../../../../../include/OpenConnection.asp" -->
<!-- #include file="../../../../../../include/DBErrorhandle.asp" -->
<%
dim Flag
Flag=Request.QueryString("Flag")
Response.ContentType="text/xml"
'Set 'xmlDoc =Server.CreateObject("Msxml2.DOMDocument.4.0")
Set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async= false
xmlDoc.load Request
'==============================================================
'函数名称:GetTemplate()
'功能:取得指定类型中得所有模板
'作者:柯依策
'日期:2002年10月16日
'===============================================================
function GetTemplate()
set oRoot=xmlDoc.documentElement
dim oRs,sSql
dim nDocTypeID
nDocTypeID=oRoot.selectSingleNode("TypeID").text
if nDocTypeID="" then
vHaveError()
end if
on Error resume Next
Set oRs=Server.CreateObject("ADODB.RecordSet")
sSql="select * from T_OA_DocTemplate where gwlbid="&nDocTypeID
oRs.Open sSql,cn,2,3
if oRs.EOF=false then
Set oRecords=xmlDoc.createElement("Records")
while Not oRs.EOF
Set oRecord=xmlDoc.createElement("Record")
Set oTempName=xmlDoc.createElement("TempName")
oTempName.text=oRs("gwmbmc")
Set oTempFile=xmlDoc.createElement("TempFile")
oTempFile.text=oRs("gwmblj")
oRecord.appendChild oTempName
oRecord.appendChild oTempFile
oRecords.appendChild oRecord
oRs.MoveNext
wend
oRoot.appendChild oRecords
end if
if Err.number>0 then
vHaveError()
else
Response.CharSet="UTF-8"
Response.ContentType="text/xml"
Response.BinaryWrite xmlDoc.xml
end if
end function
'========================================================
'函数名称:CreateDoc()
'功能:创建word文档
'返回:
'作者:柯依策
'日期:2002年10月16日
'版本:01
'=========================================================
function CreateDoc()
set oRoot=xmlDoc.documentElement
dim sDocID,sOldFile,sNewFile
sDocID=oRoot.selectSingleNode("DocID").text
sOldFile=oRoot.selectSingleNode("OldFile").text
sNewFile=oRoot.selectSingleNode("NewFile").text
if sDocID="" or sOldFile="" or sNewFile="" then
vHaveError()
end if
on Error Resume next
dim sPath,sSPath,sDPath,sDTextName
dim oSfo,oSFile,oDFile
sPath=Server.MapPath("../../../../../../OAFlow/DocuTemplate/tempDoc")
sSPath=sPath & "\" & sNewFile
'Response.Write sSPath
'目标文件信息
sDTextName="text" & right(sNewFile,len(sNewFile)-4)
sDPath=Server.MapPath("../../../../../../OAFlow/DocuTemplate/textDoc") & "\" & sDTextName
set oSfo=Server.CreateObject("Scripting.FileSystemObject")
set oSFile=oSfo.GetFile(sSPath)
oSFile.Copy sDPath
if Err.number>0 then
vHaveError()
else
sDName=sDTextName
SaveDoc sDName,sDocID
Response.AddHeader "Flag", 1
end if
end function
function SaveDoc(FileName,gwid)
on Error resume Next
dim oRs,sSql
sSql="select * from T_OA_DocText where gwid="&gwid
Set oRs=Server.CreateObject("ADODB.RecordSet")
oRs.open sSql,cn,2,3
oRs("gwzwlj")=FileName
oRs("gwid")=gwid
oRs.update
oRs.close
Set oRs=Nothing
if Err.number>0 then
vHaveError()
end if
end function
'====================================================================
'函数vHaveError() 错误处理,现在暂时是 ,如果Err.nubmer<>0 就
'在头文件输出Error=1,表示有错误,停止程序的执行。
'作者:柯依策
'时间:2002年8月30日
'====================================================================
Function vHaveError()
dim sError
'错误的描述
if Err.number<>0 then
Response.AddHeader "Error",1
Response.End
end if
End Function
Select Case Flag
Case 1
GetTemplate
case 2
CreateDoc
End Select
%>
#4
在第一个下拉框的的onchange事件里将当前选中的一项提交,再根据提交内容确定第二个下拉框的内容。
例子:
<form name="form1" method="post" action="">
<select name="select1" onchange=sum1()>
<option></option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<select name="select2">
<%
'接收数据(第一个下拉框的值)
usestr=Request("select1")
If usestr<>"" Then%>
<option><%=usestr%></option>
<%End If%>
</select>
</form>
<script language=javascript>
function sum1()
{
form1.submit();
}
</script>
具体的代码过程等等你自己再加。这是一个思路,不方便的地方就是要提交,如果没有这个必要在服务器上取得数据就不用提交。
例子:
<form name="form1" method="post" action="">
<select name="select1" onchange=sum1()>
<option></option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<select name="select2">
<%
'接收数据(第一个下拉框的值)
usestr=Request("select1")
If usestr<>"" Then%>
<option><%=usestr%></option>
<%End If%>
</select>
</form>
<script language=javascript>
function sum1()
{
form1.submit();
}
</script>
具体的代码过程等等你自己再加。这是一个思路,不方便的地方就是要提交,如果没有这个必要在服务器上取得数据就不用提交。
#5
<tr>
<td width="107" class="colName" height="16"> <div align="center">出生地</div></td>
<td colspan="5" height="16"> <select name="CSDS" style="WIDTH: 120px" onchange="changeADDRESS()">
<OPTION value="" selected>--请选择---</OPTION>
<%=oHaisCode.setOptions(CSDS)%>
</select>
省
<select name="CSDC" style="WIDTH: 130px" onchange="changeFamily()">
<OPTION value="" selected>--请选择---</OPTION>
</select>
市
<select name="CSDX" style="WIDTH: 130px">
<OPTION value=0 selected>--请选择---</OPTION>
</select>
县 </td>
</tr>
//change Address ====zhouja=====
function changeADDRESS(){
var csds=new String(form1.CSDS.value);
xmlHttp.open("POST","Address_xml.asp",false);
xmlHttp.send("<ADDRESS>" + csds +"</ADDRESS>");
xmlDoc.loadXML(xmlHttp.responseText);
// alert(xmlDoc.xml);
var curNode;
curNode=xmlDoc.selectNodes("//ADDRESS");
// alert(curNode.length);
if(curNode.length>0){
with(form1){
CSDC.length=0;
CSDX.length=0;
var tempLen=new String();
for(var i=0;i<curNode.length;i++){
tempLen=curNode.item(i).attributes.item(1).value;
if(tempLen.length==4){
CSDC.length=CSDC.length+1;
CSDC.options[CSDC.length-1].value=curNode.item(i).attributes.item(0).value;
CSDC.options[CSDC.length-1].text=curNode.item(i).text;
if(curNode.item(i).attributes.item(0).value=="<%=data(9)%>")
CSDC.options[CSDC.length-1].selected=true
}
}
}
}
changeFamily();
// alert(xmlHttp.responseText);
}
后台处理:
<!-- #include file=../../../../Inc/Script/PubFunc.asp -->
<%
Response.ContentType="text/xml"
openDB()
if Request.ServerVariables("REQUEST_METHOD")="POST" then
dim address
set xmlDocIn=server.CreateObject("microsoft.xmldom")
set xmlDocOut=server.CreateObject("microsoft.xmldom")
' set xmlDocIn=server.CreateObject("microsoft.xmldom")
' set xmlDocOut=server.CreateObject("Msxml2.DOMDocument.4.0")
xmlDocIn.load(request)
address=xmlDocIn.documentElement.text
dim rs,sql
set root=xmldocout.createElement("YLJG")
xmldocout.appendChild(root)
'*************************************显示出对应的出生地的基本信息********************************
set rs=server.CreateObject("adodb.recordset")
set objRs=server.CreateObject("adodb.recordset")
' sql="select * from YL_JBXX where YLJG_ID='"& yljg_id &"'"
sql="select VCode1 as TCode ,MCode from Sys_Code where TCode='"& address &"'"
rs.Open sql,OpenCodeDB(),1,3
if rs.EOF or rs.RecordCount>1 then
else
dim tempTCode
tempTCode=rs("TCode")
dim tempLen
tempLen=len(tempTCode)
dim zyhsNode
set zyhsNode=xmlDocOut.createElement("ZYHS")
xmlDocOut.documentElement.appendChild(zyhsNode)
' sql="select VCode,TText from Sys_TCode where left(TCode,tempLen)='"& tempTCode &"'"
sql="select TCode,Text,VCode1 from Sys_Code where left(VCode1,'"& tempLen &"')='"& tempTCode &"' and MCode='"& rs("MCode") &"'"
objRs.Open sql,OpenCodeDB(),1,3
if not objRs.EOF then
dim curNode
while not objRs.EOF
set curNode=xmlDocOut.createElement("ADDRESS")
curNode.text=objRs("Text")
xmlDocOut.documentElement.lastChild.appendChild(curNode)
set curAttr=xmlDocOut.createAttribute("VCODE")
curAttr.text=objRs("TCode")
xmlDocOut.documentElement.lastChild.lastChild.attributes.setNamedItem curAttr
set curAttr=xmlDocOut.createAttribute("TCode")
curAttr.text=objRs("VCode1")
xmlDocOut.documentElement.lastChild.lastChild.attributes.setNamedItem curAttr
objRs.MoveNext
wend
end if
objRs.Close
set objRs=nothing
end if
rs.Close
set rs=nothing
xmlDocOut.save(Response)
end if
%>
上面是根据省,读出市,在根据市读出县,够详细了吧!
<td width="107" class="colName" height="16"> <div align="center">出生地</div></td>
<td colspan="5" height="16"> <select name="CSDS" style="WIDTH: 120px" onchange="changeADDRESS()">
<OPTION value="" selected>--请选择---</OPTION>
<%=oHaisCode.setOptions(CSDS)%>
</select>
省
<select name="CSDC" style="WIDTH: 130px" onchange="changeFamily()">
<OPTION value="" selected>--请选择---</OPTION>
</select>
市
<select name="CSDX" style="WIDTH: 130px">
<OPTION value=0 selected>--请选择---</OPTION>
</select>
县 </td>
</tr>
//change Address ====zhouja=====
function changeADDRESS(){
var csds=new String(form1.CSDS.value);
xmlHttp.open("POST","Address_xml.asp",false);
xmlHttp.send("<ADDRESS>" + csds +"</ADDRESS>");
xmlDoc.loadXML(xmlHttp.responseText);
// alert(xmlDoc.xml);
var curNode;
curNode=xmlDoc.selectNodes("//ADDRESS");
// alert(curNode.length);
if(curNode.length>0){
with(form1){
CSDC.length=0;
CSDX.length=0;
var tempLen=new String();
for(var i=0;i<curNode.length;i++){
tempLen=curNode.item(i).attributes.item(1).value;
if(tempLen.length==4){
CSDC.length=CSDC.length+1;
CSDC.options[CSDC.length-1].value=curNode.item(i).attributes.item(0).value;
CSDC.options[CSDC.length-1].text=curNode.item(i).text;
if(curNode.item(i).attributes.item(0).value=="<%=data(9)%>")
CSDC.options[CSDC.length-1].selected=true
}
}
}
}
changeFamily();
// alert(xmlHttp.responseText);
}
后台处理:
<!-- #include file=../../../../Inc/Script/PubFunc.asp -->
<%
Response.ContentType="text/xml"
openDB()
if Request.ServerVariables("REQUEST_METHOD")="POST" then
dim address
set xmlDocIn=server.CreateObject("microsoft.xmldom")
set xmlDocOut=server.CreateObject("microsoft.xmldom")
' set xmlDocIn=server.CreateObject("microsoft.xmldom")
' set xmlDocOut=server.CreateObject("Msxml2.DOMDocument.4.0")
xmlDocIn.load(request)
address=xmlDocIn.documentElement.text
dim rs,sql
set root=xmldocout.createElement("YLJG")
xmldocout.appendChild(root)
'*************************************显示出对应的出生地的基本信息********************************
set rs=server.CreateObject("adodb.recordset")
set objRs=server.CreateObject("adodb.recordset")
' sql="select * from YL_JBXX where YLJG_ID='"& yljg_id &"'"
sql="select VCode1 as TCode ,MCode from Sys_Code where TCode='"& address &"'"
rs.Open sql,OpenCodeDB(),1,3
if rs.EOF or rs.RecordCount>1 then
else
dim tempTCode
tempTCode=rs("TCode")
dim tempLen
tempLen=len(tempTCode)
dim zyhsNode
set zyhsNode=xmlDocOut.createElement("ZYHS")
xmlDocOut.documentElement.appendChild(zyhsNode)
' sql="select VCode,TText from Sys_TCode where left(TCode,tempLen)='"& tempTCode &"'"
sql="select TCode,Text,VCode1 from Sys_Code where left(VCode1,'"& tempLen &"')='"& tempTCode &"' and MCode='"& rs("MCode") &"'"
objRs.Open sql,OpenCodeDB(),1,3
if not objRs.EOF then
dim curNode
while not objRs.EOF
set curNode=xmlDocOut.createElement("ADDRESS")
curNode.text=objRs("Text")
xmlDocOut.documentElement.lastChild.appendChild(curNode)
set curAttr=xmlDocOut.createAttribute("VCODE")
curAttr.text=objRs("TCode")
xmlDocOut.documentElement.lastChild.lastChild.attributes.setNamedItem curAttr
set curAttr=xmlDocOut.createAttribute("TCode")
curAttr.text=objRs("VCode1")
xmlDocOut.documentElement.lastChild.lastChild.attributes.setNamedItem curAttr
objRs.MoveNext
wend
end if
objRs.Close
set objRs=nothing
end if
rs.Close
set rs=nothing
xmlDocOut.save(Response)
end if
%>
上面是根据省,读出市,在根据市读出县,够详细了吧!
#6
thank 各位!我先用用,然后再提问题呀!
#7
这个简单,容易分析,自己改进:
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(){
form1.textfield.value=form1.menu1.value
}
//-->
</script>
<%
if request.Form("submit")<>"" then
response.Write(request.Form("textfield"))
response.End()
end if
%>
<form name="form1" action="" method="post">
<select name="menu1" onChange="MM_jumpMenu()">
<option selected value="选1">1</option>
<option value="选2">2</option>
<option value="选3">3</option>
</select>
<input type="text" name="textfield">
<input type="submit" name="Submit" value="Submit">
</form>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(){
form1.textfield.value=form1.menu1.value
}
//-->
</script>
<%
if request.Form("submit")<>"" then
response.Write(request.Form("textfield"))
response.End()
end if
%>
<form name="form1" action="" method="post">
<select name="menu1" onChange="MM_jumpMenu()">
<option selected value="选1">1</option>
<option value="选2">2</option>
<option value="选3">3</option>
</select>
<input type="text" name="textfield">
<input type="submit" name="Submit" value="Submit">
</form>
#8
给分呀。
#1
一个例子
function ch(selectedids,n)
{
var selectedvalue=selectedids
var i
var t=0
document.form1.s2.length=0
for(i=0;i<n;i++)
{
if(subcat[i][0]==selectedvalue)
{
document.form1.s2.options[t]=new Option(subcat[i][1],subcat[i][2])
t=t+1
}
}
}
function check()
{
if (document.form1.s1.options.selectedIndex==0)
{
alert("请先选择类别")
document.form1.s1.focus()
return false
}
return true
}
/* function beginT(){
var t=window.showModalDialog("../calendar/calendar.htm",null,"dialogWidth:208px;dialogHeight:240px;status:no;help:no");
if (t!=null){
document.form1.T_in.value=t;
}
return;
}*/
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="780" border="0" cellspacing="0" cellpadding="0" height="38%" bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr>
<td width="81%" height="478" valign="top">
<form name="form1" method="post" action="do_mod.asp" onsubmit="return datacheck()">
<table width="100%" border="0">
<tr bgcolor="#E6E0FE">
<td width="12%" align="center">
物品类别
</td>
<td colspan="6">
<script language="javascript">
var subcat=new Array()
<%dim n
n=0
set rs=server.CreateObject("adodb.recordset")
rs.ActiveConnection=conn
rs.Source="select a.T_catid,a.T_name as xx ,a.T_id from cos_T_manage a join cos_T_catagery b on a.T_catid=b.T_id"
rs.CursorType=1
rs.LockType=1
rs.Open
do while not rs.EOF%>
subcat[<%=n%>]=new Array("<%=rs("T_catid")%>","<%=rs("xx")%>","<%=rs("T_id")%>")
<%n=n+1
rs.movenext
loop%>
</script>
<select name="s1" onchange="ch(this.options[this.selectedIndex].value,<%=n%>)">
<option value="0">--请选择--</option>
<%set rsd=server.CreateObject("adodb.recordset")
rsd.ActiveConnection=conn
rsd.Source="select T_id,T_name from cos_t_catagery"
rsd.Open
do while not rsd.EOF
%>
<option value="<%=rsd("T_id")%>">
<%=rsd("T_name")%>
</option>
<%rsd.MoveNext
loop
%>
</select>
</td>
</tr>
<tr bgcolor="#E6E0FE"><td width="12%" align="center">
物品名称
</td>
<td colspan="6">
<select name="s2" onclick="check()"> </select>
</td>
function ch(selectedids,n)
{
var selectedvalue=selectedids
var i
var t=0
document.form1.s2.length=0
for(i=0;i<n;i++)
{
if(subcat[i][0]==selectedvalue)
{
document.form1.s2.options[t]=new Option(subcat[i][1],subcat[i][2])
t=t+1
}
}
}
function check()
{
if (document.form1.s1.options.selectedIndex==0)
{
alert("请先选择类别")
document.form1.s1.focus()
return false
}
return true
}
/* function beginT(){
var t=window.showModalDialog("../calendar/calendar.htm",null,"dialogWidth:208px;dialogHeight:240px;status:no;help:no");
if (t!=null){
document.form1.T_in.value=t;
}
return;
}*/
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="780" border="0" cellspacing="0" cellpadding="0" height="38%" bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr>
<td width="81%" height="478" valign="top">
<form name="form1" method="post" action="do_mod.asp" onsubmit="return datacheck()">
<table width="100%" border="0">
<tr bgcolor="#E6E0FE">
<td width="12%" align="center">
物品类别
</td>
<td colspan="6">
<script language="javascript">
var subcat=new Array()
<%dim n
n=0
set rs=server.CreateObject("adodb.recordset")
rs.ActiveConnection=conn
rs.Source="select a.T_catid,a.T_name as xx ,a.T_id from cos_T_manage a join cos_T_catagery b on a.T_catid=b.T_id"
rs.CursorType=1
rs.LockType=1
rs.Open
do while not rs.EOF%>
subcat[<%=n%>]=new Array("<%=rs("T_catid")%>","<%=rs("xx")%>","<%=rs("T_id")%>")
<%n=n+1
rs.movenext
loop%>
</script>
<select name="s1" onchange="ch(this.options[this.selectedIndex].value,<%=n%>)">
<option value="0">--请选择--</option>
<%set rsd=server.CreateObject("adodb.recordset")
rsd.ActiveConnection=conn
rsd.Source="select T_id,T_name from cos_t_catagery"
rsd.Open
do while not rsd.EOF
%>
<option value="<%=rsd("T_id")%>">
<%=rsd("T_name")%>
</option>
<%rsd.MoveNext
loop
%>
</select>
</td>
</tr>
<tr bgcolor="#E6E0FE"><td width="12%" align="center">
物品名称
</td>
<td colspan="6">
<select name="s2" onclick="check()"> </select>
</td>
#2
<!-- #include file="../../../../../include/OpenConnection.asp" -->
<!--#include file="../../../../../include/adovbs.inc"-->
<%
function OutPutTemptype()
dim oRs,sSql
Set oRs=Server.CreateObject("ADODB.RecordSet")
sSql="select * from T_OA_DocType where gwlbyxbz=1"
oRs.Open sSql,cn,2,3
while Not oRs.EOF
Response.Write "<option value='"&oRs("gwlbid")&"'>"&oRs("gwlbmc")&"</option>"
oRs.MoveNext
wend
oRs.Close
Set oRs=Nothing
end function
%>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<link rel="stylesheet" href="../../../../../csslib/fwstyle.css" type="text/css">
<Script language = "javaScript" src = "../../../../../include/MSAlert.js"></Script>
<script language="vbscript" src="../../../../../include/LimitInput.vbs"></script>
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>选择公文模板</title>
<script language="javascript">
/*=======================================================================
函数名称:GetTemplate()
功能:取得本类型所有得公文模板列表
参数:DocTypeID 模板类型内码
返回:
作者:柯依策
=========================================================================*/
function GetTemplate(DocTypeID){
var xmlDoc,xmlHttp
xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
var oRoot=xmlDoc.createElement("Root")
var oTypeID=xmlDoc.createElement("TypeID")
oTypeID.text=DocTypeID
oRoot.appendChild(oTypeID)
xmlDoc.appendChild(oRoot)
xmlHttp.open("POST","include/DataTemplate.asp?flag=1",false)
xmlHttp.send(xmlDoc)
if(xmlHttp.readyState==4) {
var ErrNumber=xmlHttp.getResponseHeader("Error")
if(ErrNumber!=""){
MWalert(1,"系统出错,等会在操作!")
}
else{
xmlDoc.loadXML(xmlHttp.responseBody) //返回xml文档
var oNodeList=xmlDoc.selectNodes("//Record")
form1.selDocTemplate.length=0
for(var i=0;i<oNodeList.length;i++){
var oOption=document.createElement("Option")
var sValue=oNodeList(i).selectSingleNode("TempFile").text
var sText=oNodeList(i).selectSingleNode("TempName").text
oOption.value=sValue
oOption.text=sText
form1.selDocTemplate.add(oOption)
}
}
}
}
/*=============================================================================
===============================================================================*/
function InitDoc(){
var sDefTypeID=form1.selDocType.value
if(sDefTypeID==""){
return false
}
GetTemplate(sDefTypeID)
}
function DocTypeChange(){
var TypeID=form1.selDocType.value
GetTemplate(TypeID)
}
function SaveClick(){
window.returnValue=form1.selDocTemplate.value
window.close()
}
function CancelClick(){
window.returnValue=""
window.close()
}
function PreviewClick(){
var FileName=form1.selDocTemplate.value
if(FileName==""){
MWalert(1,"请选择公文模板!")
return false;
}
var sPath="../../../../../OAflow/DocuTemplate/textDoc.asp?FileName=" + FileName
try{
varibles=showModalDialog(sPath,"","dialogHeight:550px; dialogWidth:750px; help: No;status: No; ")
}
catch(e){
}
}
</script>
</head>
<body bgcolor="#8CBEF7" topmargin=0 leftmargin=0 onload="InitDoc()" onunload="">
<form method="post" name="form1" action="">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="140">
<tr>
<td width="100%" height="33" align="center" colspan="2"><b>
<font size="3">公文模板库</font></b></td>
</tr>
<tr>
<td width="50%" height="39" align="right">模板类型:</td>
<td width="50%" height="39">
<select size="1" name="selDocType" style="width:200" class="selOA" onchange="DocTypeChange()">
<%OutPutTemptype()%>
</select></td>
</tr>
<tr>
<td width="50%" height="39" align="right">模板列表:</td>
<td width="50%" height="39">
<select size="1" name="selDocTemplate" style="width:200" class="selOA"></select></td>
</tr>
<tr>
<td width="100%" height="52" colspan="2">
<p align="center">
<input type="button" value="预览" name="btPreview" class="btnStandard" onclick="PreviewClick()">
<input type="button" value="确定" name="btSave" class="btnStandard" onclick="SaveClick()">
<input type="button" value="取消" name="btCancel" class="btnStandard" onclick="CancelClick()">
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
<!--#include file="../../../../../include/adovbs.inc"-->
<%
function OutPutTemptype()
dim oRs,sSql
Set oRs=Server.CreateObject("ADODB.RecordSet")
sSql="select * from T_OA_DocType where gwlbyxbz=1"
oRs.Open sSql,cn,2,3
while Not oRs.EOF
Response.Write "<option value='"&oRs("gwlbid")&"'>"&oRs("gwlbmc")&"</option>"
oRs.MoveNext
wend
oRs.Close
Set oRs=Nothing
end function
%>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<link rel="stylesheet" href="../../../../../csslib/fwstyle.css" type="text/css">
<Script language = "javaScript" src = "../../../../../include/MSAlert.js"></Script>
<script language="vbscript" src="../../../../../include/LimitInput.vbs"></script>
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>选择公文模板</title>
<script language="javascript">
/*=======================================================================
函数名称:GetTemplate()
功能:取得本类型所有得公文模板列表
参数:DocTypeID 模板类型内码
返回:
作者:柯依策
=========================================================================*/
function GetTemplate(DocTypeID){
var xmlDoc,xmlHttp
xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
var oRoot=xmlDoc.createElement("Root")
var oTypeID=xmlDoc.createElement("TypeID")
oTypeID.text=DocTypeID
oRoot.appendChild(oTypeID)
xmlDoc.appendChild(oRoot)
xmlHttp.open("POST","include/DataTemplate.asp?flag=1",false)
xmlHttp.send(xmlDoc)
if(xmlHttp.readyState==4) {
var ErrNumber=xmlHttp.getResponseHeader("Error")
if(ErrNumber!=""){
MWalert(1,"系统出错,等会在操作!")
}
else{
xmlDoc.loadXML(xmlHttp.responseBody) //返回xml文档
var oNodeList=xmlDoc.selectNodes("//Record")
form1.selDocTemplate.length=0
for(var i=0;i<oNodeList.length;i++){
var oOption=document.createElement("Option")
var sValue=oNodeList(i).selectSingleNode("TempFile").text
var sText=oNodeList(i).selectSingleNode("TempName").text
oOption.value=sValue
oOption.text=sText
form1.selDocTemplate.add(oOption)
}
}
}
}
/*=============================================================================
===============================================================================*/
function InitDoc(){
var sDefTypeID=form1.selDocType.value
if(sDefTypeID==""){
return false
}
GetTemplate(sDefTypeID)
}
function DocTypeChange(){
var TypeID=form1.selDocType.value
GetTemplate(TypeID)
}
function SaveClick(){
window.returnValue=form1.selDocTemplate.value
window.close()
}
function CancelClick(){
window.returnValue=""
window.close()
}
function PreviewClick(){
var FileName=form1.selDocTemplate.value
if(FileName==""){
MWalert(1,"请选择公文模板!")
return false;
}
var sPath="../../../../../OAflow/DocuTemplate/textDoc.asp?FileName=" + FileName
try{
varibles=showModalDialog(sPath,"","dialogHeight:550px; dialogWidth:750px; help: No;status: No; ")
}
catch(e){
}
}
</script>
</head>
<body bgcolor="#8CBEF7" topmargin=0 leftmargin=0 onload="InitDoc()" onunload="">
<form method="post" name="form1" action="">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="140">
<tr>
<td width="100%" height="33" align="center" colspan="2"><b>
<font size="3">公文模板库</font></b></td>
</tr>
<tr>
<td width="50%" height="39" align="right">模板类型:</td>
<td width="50%" height="39">
<select size="1" name="selDocType" style="width:200" class="selOA" onchange="DocTypeChange()">
<%OutPutTemptype()%>
</select></td>
</tr>
<tr>
<td width="50%" height="39" align="right">模板列表:</td>
<td width="50%" height="39">
<select size="1" name="selDocTemplate" style="width:200" class="selOA"></select></td>
</tr>
<tr>
<td width="100%" height="52" colspan="2">
<p align="center">
<input type="button" value="预览" name="btPreview" class="btnStandard" onclick="PreviewClick()">
<input type="button" value="确定" name="btSave" class="btnStandard" onclick="SaveClick()">
<input type="button" value="取消" name="btCancel" class="btnStandard" onclick="CancelClick()">
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
#3
//后台数据 datatemplate.asp
<!-- #include file="../../../../../../include/OpenConnection.asp" -->
<!-- #include file="../../../../../../include/DBErrorhandle.asp" -->
<%
dim Flag
Flag=Request.QueryString("Flag")
Response.ContentType="text/xml"
'Set 'xmlDoc =Server.CreateObject("Msxml2.DOMDocument.4.0")
Set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async= false
xmlDoc.load Request
'==============================================================
'函数名称:GetTemplate()
'功能:取得指定类型中得所有模板
'作者:柯依策
'日期:2002年10月16日
'===============================================================
function GetTemplate()
set oRoot=xmlDoc.documentElement
dim oRs,sSql
dim nDocTypeID
nDocTypeID=oRoot.selectSingleNode("TypeID").text
if nDocTypeID="" then
vHaveError()
end if
on Error resume Next
Set oRs=Server.CreateObject("ADODB.RecordSet")
sSql="select * from T_OA_DocTemplate where gwlbid="&nDocTypeID
oRs.Open sSql,cn,2,3
if oRs.EOF=false then
Set oRecords=xmlDoc.createElement("Records")
while Not oRs.EOF
Set oRecord=xmlDoc.createElement("Record")
Set oTempName=xmlDoc.createElement("TempName")
oTempName.text=oRs("gwmbmc")
Set oTempFile=xmlDoc.createElement("TempFile")
oTempFile.text=oRs("gwmblj")
oRecord.appendChild oTempName
oRecord.appendChild oTempFile
oRecords.appendChild oRecord
oRs.MoveNext
wend
oRoot.appendChild oRecords
end if
if Err.number>0 then
vHaveError()
else
Response.CharSet="UTF-8"
Response.ContentType="text/xml"
Response.BinaryWrite xmlDoc.xml
end if
end function
'========================================================
'函数名称:CreateDoc()
'功能:创建word文档
'返回:
'作者:柯依策
'日期:2002年10月16日
'版本:01
'=========================================================
function CreateDoc()
set oRoot=xmlDoc.documentElement
dim sDocID,sOldFile,sNewFile
sDocID=oRoot.selectSingleNode("DocID").text
sOldFile=oRoot.selectSingleNode("OldFile").text
sNewFile=oRoot.selectSingleNode("NewFile").text
if sDocID="" or sOldFile="" or sNewFile="" then
vHaveError()
end if
on Error Resume next
dim sPath,sSPath,sDPath,sDTextName
dim oSfo,oSFile,oDFile
sPath=Server.MapPath("../../../../../../OAFlow/DocuTemplate/tempDoc")
sSPath=sPath & "\" & sNewFile
'Response.Write sSPath
'目标文件信息
sDTextName="text" & right(sNewFile,len(sNewFile)-4)
sDPath=Server.MapPath("../../../../../../OAFlow/DocuTemplate/textDoc") & "\" & sDTextName
set oSfo=Server.CreateObject("Scripting.FileSystemObject")
set oSFile=oSfo.GetFile(sSPath)
oSFile.Copy sDPath
if Err.number>0 then
vHaveError()
else
sDName=sDTextName
SaveDoc sDName,sDocID
Response.AddHeader "Flag", 1
end if
end function
function SaveDoc(FileName,gwid)
on Error resume Next
dim oRs,sSql
sSql="select * from T_OA_DocText where gwid="&gwid
Set oRs=Server.CreateObject("ADODB.RecordSet")
oRs.open sSql,cn,2,3
oRs("gwzwlj")=FileName
oRs("gwid")=gwid
oRs.update
oRs.close
Set oRs=Nothing
if Err.number>0 then
vHaveError()
end if
end function
'====================================================================
'函数vHaveError() 错误处理,现在暂时是 ,如果Err.nubmer<>0 就
'在头文件输出Error=1,表示有错误,停止程序的执行。
'作者:柯依策
'时间:2002年8月30日
'====================================================================
Function vHaveError()
dim sError
'错误的描述
if Err.number<>0 then
Response.AddHeader "Error",1
Response.End
end if
End Function
Select Case Flag
Case 1
GetTemplate
case 2
CreateDoc
End Select
%>
<!-- #include file="../../../../../../include/OpenConnection.asp" -->
<!-- #include file="../../../../../../include/DBErrorhandle.asp" -->
<%
dim Flag
Flag=Request.QueryString("Flag")
Response.ContentType="text/xml"
'Set 'xmlDoc =Server.CreateObject("Msxml2.DOMDocument.4.0")
Set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async= false
xmlDoc.load Request
'==============================================================
'函数名称:GetTemplate()
'功能:取得指定类型中得所有模板
'作者:柯依策
'日期:2002年10月16日
'===============================================================
function GetTemplate()
set oRoot=xmlDoc.documentElement
dim oRs,sSql
dim nDocTypeID
nDocTypeID=oRoot.selectSingleNode("TypeID").text
if nDocTypeID="" then
vHaveError()
end if
on Error resume Next
Set oRs=Server.CreateObject("ADODB.RecordSet")
sSql="select * from T_OA_DocTemplate where gwlbid="&nDocTypeID
oRs.Open sSql,cn,2,3
if oRs.EOF=false then
Set oRecords=xmlDoc.createElement("Records")
while Not oRs.EOF
Set oRecord=xmlDoc.createElement("Record")
Set oTempName=xmlDoc.createElement("TempName")
oTempName.text=oRs("gwmbmc")
Set oTempFile=xmlDoc.createElement("TempFile")
oTempFile.text=oRs("gwmblj")
oRecord.appendChild oTempName
oRecord.appendChild oTempFile
oRecords.appendChild oRecord
oRs.MoveNext
wend
oRoot.appendChild oRecords
end if
if Err.number>0 then
vHaveError()
else
Response.CharSet="UTF-8"
Response.ContentType="text/xml"
Response.BinaryWrite xmlDoc.xml
end if
end function
'========================================================
'函数名称:CreateDoc()
'功能:创建word文档
'返回:
'作者:柯依策
'日期:2002年10月16日
'版本:01
'=========================================================
function CreateDoc()
set oRoot=xmlDoc.documentElement
dim sDocID,sOldFile,sNewFile
sDocID=oRoot.selectSingleNode("DocID").text
sOldFile=oRoot.selectSingleNode("OldFile").text
sNewFile=oRoot.selectSingleNode("NewFile").text
if sDocID="" or sOldFile="" or sNewFile="" then
vHaveError()
end if
on Error Resume next
dim sPath,sSPath,sDPath,sDTextName
dim oSfo,oSFile,oDFile
sPath=Server.MapPath("../../../../../../OAFlow/DocuTemplate/tempDoc")
sSPath=sPath & "\" & sNewFile
'Response.Write sSPath
'目标文件信息
sDTextName="text" & right(sNewFile,len(sNewFile)-4)
sDPath=Server.MapPath("../../../../../../OAFlow/DocuTemplate/textDoc") & "\" & sDTextName
set oSfo=Server.CreateObject("Scripting.FileSystemObject")
set oSFile=oSfo.GetFile(sSPath)
oSFile.Copy sDPath
if Err.number>0 then
vHaveError()
else
sDName=sDTextName
SaveDoc sDName,sDocID
Response.AddHeader "Flag", 1
end if
end function
function SaveDoc(FileName,gwid)
on Error resume Next
dim oRs,sSql
sSql="select * from T_OA_DocText where gwid="&gwid
Set oRs=Server.CreateObject("ADODB.RecordSet")
oRs.open sSql,cn,2,3
oRs("gwzwlj")=FileName
oRs("gwid")=gwid
oRs.update
oRs.close
Set oRs=Nothing
if Err.number>0 then
vHaveError()
end if
end function
'====================================================================
'函数vHaveError() 错误处理,现在暂时是 ,如果Err.nubmer<>0 就
'在头文件输出Error=1,表示有错误,停止程序的执行。
'作者:柯依策
'时间:2002年8月30日
'====================================================================
Function vHaveError()
dim sError
'错误的描述
if Err.number<>0 then
Response.AddHeader "Error",1
Response.End
end if
End Function
Select Case Flag
Case 1
GetTemplate
case 2
CreateDoc
End Select
%>
#4
在第一个下拉框的的onchange事件里将当前选中的一项提交,再根据提交内容确定第二个下拉框的内容。
例子:
<form name="form1" method="post" action="">
<select name="select1" onchange=sum1()>
<option></option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<select name="select2">
<%
'接收数据(第一个下拉框的值)
usestr=Request("select1")
If usestr<>"" Then%>
<option><%=usestr%></option>
<%End If%>
</select>
</form>
<script language=javascript>
function sum1()
{
form1.submit();
}
</script>
具体的代码过程等等你自己再加。这是一个思路,不方便的地方就是要提交,如果没有这个必要在服务器上取得数据就不用提交。
例子:
<form name="form1" method="post" action="">
<select name="select1" onchange=sum1()>
<option></option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<select name="select2">
<%
'接收数据(第一个下拉框的值)
usestr=Request("select1")
If usestr<>"" Then%>
<option><%=usestr%></option>
<%End If%>
</select>
</form>
<script language=javascript>
function sum1()
{
form1.submit();
}
</script>
具体的代码过程等等你自己再加。这是一个思路,不方便的地方就是要提交,如果没有这个必要在服务器上取得数据就不用提交。
#5
<tr>
<td width="107" class="colName" height="16"> <div align="center">出生地</div></td>
<td colspan="5" height="16"> <select name="CSDS" style="WIDTH: 120px" onchange="changeADDRESS()">
<OPTION value="" selected>--请选择---</OPTION>
<%=oHaisCode.setOptions(CSDS)%>
</select>
省
<select name="CSDC" style="WIDTH: 130px" onchange="changeFamily()">
<OPTION value="" selected>--请选择---</OPTION>
</select>
市
<select name="CSDX" style="WIDTH: 130px">
<OPTION value=0 selected>--请选择---</OPTION>
</select>
县 </td>
</tr>
//change Address ====zhouja=====
function changeADDRESS(){
var csds=new String(form1.CSDS.value);
xmlHttp.open("POST","Address_xml.asp",false);
xmlHttp.send("<ADDRESS>" + csds +"</ADDRESS>");
xmlDoc.loadXML(xmlHttp.responseText);
// alert(xmlDoc.xml);
var curNode;
curNode=xmlDoc.selectNodes("//ADDRESS");
// alert(curNode.length);
if(curNode.length>0){
with(form1){
CSDC.length=0;
CSDX.length=0;
var tempLen=new String();
for(var i=0;i<curNode.length;i++){
tempLen=curNode.item(i).attributes.item(1).value;
if(tempLen.length==4){
CSDC.length=CSDC.length+1;
CSDC.options[CSDC.length-1].value=curNode.item(i).attributes.item(0).value;
CSDC.options[CSDC.length-1].text=curNode.item(i).text;
if(curNode.item(i).attributes.item(0).value=="<%=data(9)%>")
CSDC.options[CSDC.length-1].selected=true
}
}
}
}
changeFamily();
// alert(xmlHttp.responseText);
}
后台处理:
<!-- #include file=../../../../Inc/Script/PubFunc.asp -->
<%
Response.ContentType="text/xml"
openDB()
if Request.ServerVariables("REQUEST_METHOD")="POST" then
dim address
set xmlDocIn=server.CreateObject("microsoft.xmldom")
set xmlDocOut=server.CreateObject("microsoft.xmldom")
' set xmlDocIn=server.CreateObject("microsoft.xmldom")
' set xmlDocOut=server.CreateObject("Msxml2.DOMDocument.4.0")
xmlDocIn.load(request)
address=xmlDocIn.documentElement.text
dim rs,sql
set root=xmldocout.createElement("YLJG")
xmldocout.appendChild(root)
'*************************************显示出对应的出生地的基本信息********************************
set rs=server.CreateObject("adodb.recordset")
set objRs=server.CreateObject("adodb.recordset")
' sql="select * from YL_JBXX where YLJG_ID='"& yljg_id &"'"
sql="select VCode1 as TCode ,MCode from Sys_Code where TCode='"& address &"'"
rs.Open sql,OpenCodeDB(),1,3
if rs.EOF or rs.RecordCount>1 then
else
dim tempTCode
tempTCode=rs("TCode")
dim tempLen
tempLen=len(tempTCode)
dim zyhsNode
set zyhsNode=xmlDocOut.createElement("ZYHS")
xmlDocOut.documentElement.appendChild(zyhsNode)
' sql="select VCode,TText from Sys_TCode where left(TCode,tempLen)='"& tempTCode &"'"
sql="select TCode,Text,VCode1 from Sys_Code where left(VCode1,'"& tempLen &"')='"& tempTCode &"' and MCode='"& rs("MCode") &"'"
objRs.Open sql,OpenCodeDB(),1,3
if not objRs.EOF then
dim curNode
while not objRs.EOF
set curNode=xmlDocOut.createElement("ADDRESS")
curNode.text=objRs("Text")
xmlDocOut.documentElement.lastChild.appendChild(curNode)
set curAttr=xmlDocOut.createAttribute("VCODE")
curAttr.text=objRs("TCode")
xmlDocOut.documentElement.lastChild.lastChild.attributes.setNamedItem curAttr
set curAttr=xmlDocOut.createAttribute("TCode")
curAttr.text=objRs("VCode1")
xmlDocOut.documentElement.lastChild.lastChild.attributes.setNamedItem curAttr
objRs.MoveNext
wend
end if
objRs.Close
set objRs=nothing
end if
rs.Close
set rs=nothing
xmlDocOut.save(Response)
end if
%>
上面是根据省,读出市,在根据市读出县,够详细了吧!
<td width="107" class="colName" height="16"> <div align="center">出生地</div></td>
<td colspan="5" height="16"> <select name="CSDS" style="WIDTH: 120px" onchange="changeADDRESS()">
<OPTION value="" selected>--请选择---</OPTION>
<%=oHaisCode.setOptions(CSDS)%>
</select>
省
<select name="CSDC" style="WIDTH: 130px" onchange="changeFamily()">
<OPTION value="" selected>--请选择---</OPTION>
</select>
市
<select name="CSDX" style="WIDTH: 130px">
<OPTION value=0 selected>--请选择---</OPTION>
</select>
县 </td>
</tr>
//change Address ====zhouja=====
function changeADDRESS(){
var csds=new String(form1.CSDS.value);
xmlHttp.open("POST","Address_xml.asp",false);
xmlHttp.send("<ADDRESS>" + csds +"</ADDRESS>");
xmlDoc.loadXML(xmlHttp.responseText);
// alert(xmlDoc.xml);
var curNode;
curNode=xmlDoc.selectNodes("//ADDRESS");
// alert(curNode.length);
if(curNode.length>0){
with(form1){
CSDC.length=0;
CSDX.length=0;
var tempLen=new String();
for(var i=0;i<curNode.length;i++){
tempLen=curNode.item(i).attributes.item(1).value;
if(tempLen.length==4){
CSDC.length=CSDC.length+1;
CSDC.options[CSDC.length-1].value=curNode.item(i).attributes.item(0).value;
CSDC.options[CSDC.length-1].text=curNode.item(i).text;
if(curNode.item(i).attributes.item(0).value=="<%=data(9)%>")
CSDC.options[CSDC.length-1].selected=true
}
}
}
}
changeFamily();
// alert(xmlHttp.responseText);
}
后台处理:
<!-- #include file=../../../../Inc/Script/PubFunc.asp -->
<%
Response.ContentType="text/xml"
openDB()
if Request.ServerVariables("REQUEST_METHOD")="POST" then
dim address
set xmlDocIn=server.CreateObject("microsoft.xmldom")
set xmlDocOut=server.CreateObject("microsoft.xmldom")
' set xmlDocIn=server.CreateObject("microsoft.xmldom")
' set xmlDocOut=server.CreateObject("Msxml2.DOMDocument.4.0")
xmlDocIn.load(request)
address=xmlDocIn.documentElement.text
dim rs,sql
set root=xmldocout.createElement("YLJG")
xmldocout.appendChild(root)
'*************************************显示出对应的出生地的基本信息********************************
set rs=server.CreateObject("adodb.recordset")
set objRs=server.CreateObject("adodb.recordset")
' sql="select * from YL_JBXX where YLJG_ID='"& yljg_id &"'"
sql="select VCode1 as TCode ,MCode from Sys_Code where TCode='"& address &"'"
rs.Open sql,OpenCodeDB(),1,3
if rs.EOF or rs.RecordCount>1 then
else
dim tempTCode
tempTCode=rs("TCode")
dim tempLen
tempLen=len(tempTCode)
dim zyhsNode
set zyhsNode=xmlDocOut.createElement("ZYHS")
xmlDocOut.documentElement.appendChild(zyhsNode)
' sql="select VCode,TText from Sys_TCode where left(TCode,tempLen)='"& tempTCode &"'"
sql="select TCode,Text,VCode1 from Sys_Code where left(VCode1,'"& tempLen &"')='"& tempTCode &"' and MCode='"& rs("MCode") &"'"
objRs.Open sql,OpenCodeDB(),1,3
if not objRs.EOF then
dim curNode
while not objRs.EOF
set curNode=xmlDocOut.createElement("ADDRESS")
curNode.text=objRs("Text")
xmlDocOut.documentElement.lastChild.appendChild(curNode)
set curAttr=xmlDocOut.createAttribute("VCODE")
curAttr.text=objRs("TCode")
xmlDocOut.documentElement.lastChild.lastChild.attributes.setNamedItem curAttr
set curAttr=xmlDocOut.createAttribute("TCode")
curAttr.text=objRs("VCode1")
xmlDocOut.documentElement.lastChild.lastChild.attributes.setNamedItem curAttr
objRs.MoveNext
wend
end if
objRs.Close
set objRs=nothing
end if
rs.Close
set rs=nothing
xmlDocOut.save(Response)
end if
%>
上面是根据省,读出市,在根据市读出县,够详细了吧!
#6
thank 各位!我先用用,然后再提问题呀!
#7
这个简单,容易分析,自己改进:
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(){
form1.textfield.value=form1.menu1.value
}
//-->
</script>
<%
if request.Form("submit")<>"" then
response.Write(request.Form("textfield"))
response.End()
end if
%>
<form name="form1" action="" method="post">
<select name="menu1" onChange="MM_jumpMenu()">
<option selected value="选1">1</option>
<option value="选2">2</option>
<option value="选3">3</option>
</select>
<input type="text" name="textfield">
<input type="submit" name="Submit" value="Submit">
</form>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(){
form1.textfield.value=form1.menu1.value
}
//-->
</script>
<%
if request.Form("submit")<>"" then
response.Write(request.Form("textfield"))
response.End()
end if
%>
<form name="form1" action="" method="post">
<select name="menu1" onChange="MM_jumpMenu()">
<option selected value="选1">1</option>
<option value="选2">2</option>
<option value="选3">3</option>
</select>
<input type="text" name="textfield">
<input type="submit" name="Submit" value="Submit">
</form>
#8
给分呀。