📄 tie1.jsp
字号:
<%@ page contentType="text/html;charset=UTF-8" language="java"
import="java.util.*,domain.*" pageEncoding="UTF-8"%>
<script language="javascript">
function cle(){
document.getElementById("word").value="";
}
</script>
<script language="javascript">
function createXHR(){
var xhr;
try{
xhr = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}catch(ee){
xhr = false;
}
}
if(!xhr&&typeof XMLHttpRequest != 'undefined'){
xhr = new XMLHttpRequest();
}
return xhr;
}
function initSelArray() {
selArray = arguments; //arguments对象包含了传入的所有参数
}
var req;
function getZonglei(selectedId, targetId){
if (selectedId == "") { //selectedId为空串表示选中了默认项
clearSubSel(targetId); //清除目标列表及下级列表中的选项
return; //直接结束函数调用,不必向服务器请求信息
}
targetSelId = targetId;
req = createXHR();
req.open("get","ajaxzhonglei",true);
req.onreadystatechange = zongleiRequest;
req.send(null);
}
function zongleiRequest(){
if(req.readyState == 4){
if(req.status == 200){
zongleiList();
}else{
alert("您所请求的页面有异常。");
}
}
}
function zongleiList(){
var product = document.getElementById("productA");
var doc = new ActiveXObject("MSxml2.DOMDocument");
doc.loadXML(req.responseText);
var results = doc.getElementsByTagName("name");
var option = null;
for(var i = 0; i < results.length; i++) {
var option = document.createElement("option");
option.appendChild(document.createTextNode(results[i].firstChild.nodeValue));
option.setAttribute("value",results[i].firstChild.nodeValue);
product.appendChild(option);
}
}
function getSelected(selectedId, targetId){
//selectedId为空串表示选中了默认项
clearSubSel(targetId); //清除目标列表及下级列表中的选项
//直接结束函数调用,不必向服务器请求信息
targetSelId = targetId;
req = createXHR();
var title = document.getElementById("productA").value;
document.bussiness.text1.value = title; //给TEXT值
req.open("get","ajaxtie1?title="+title,true);
req.onreadystatechange = handleRequest;
req.send(null);
}
function handleRequest(){
if(req.readyState == 4){
if(req.status == 200){
updateList();
}else{
alert("您所请求的页面有异常。");
}
}
}
// 更新列表框中列表项函数
function updateList() {
var product = document.getElementById("productB");
var doc = new ActiveXObject("MSxml2.DOMDocument");
doc.loadXML(req.responseText);
var results = doc.getElementsByTagName("name");
var option = null;
for(var i = 0; i < results.length; i++) {
var option = document.createElement("option");
option.appendChild(document.createTextNode(results[i].firstChild.nodeValue));
option.setAttribute("value",results[i].firstChild.nodeValue);
product.appendChild(option);
}
}
function getSelectedA(selectedId, targetId){
//selectedId为空串表示选中了默认项
clearSubSel(targetId); //清除目标列表及下级列表中的选项
//直接结束函数调用,不必向服务器请求信息
targetSelId = targetId;
req = createXHR();
var title = document.getElementById("productB").value;
document.bussiness.text2.value = title;
req.open("get","ajaxtie1?title="+title,true);
req.onreadystatechange = handleRequestA;
req.send(null);
}
function handleRequestA(){
if(req.readyState == 4){
if(req.status == 200){
updateListA();
}else{
alert("您所请求的页面有异常。");
}
}
}
// 更新列表框中列表项函数
function updateListA() {
var product = document.getElementById("productC");
var doc = new ActiveXObject("MSxml2.DOMDocument");
doc.loadXML(req.responseText);
var results = doc.getElementsByTagName("name");
var option = null;
for(var i = 0; i < results.length; i++) {
var option = document.createElement("option");
option.appendChild(document.createTextNode(results[i].firstChild.nodeValue));
option.setAttribute("value",results[i].firstChild.nodeValue);
product.appendChild(option);
}
}
function getSelectedB(selectedId, targetId){
//selectedId为空串表示选中了默认项
clearSubSel(targetId); //清除目标列表及下级列表中的选项
targetSelId = targetId;
req = createXHR();
var title = document.getElementById("productC").value;
document.bussiness.text3.value = title;
req.open("get","ajaxtie1?title="+title,true);
req.onreadystatechange = handleRequestB;
req.send(null);
}
function handleRequestB(){
if(req.readyState == 4){
if(req.status == 200){
updateListB();
}else{
alert("您所请求的页面有异常。");
}
}
}
// 更新列表框中列表项函数
function updateListB() {
var product = document.getElementById("productD");
var doc = new ActiveXObject("MSxml2.DOMDocument");
doc.loadXML(req.responseText);
var results = doc.getElementsByTagName("name");
var option = null;
for(var i = 0; i < results.length; i++) {
var option = document.createElement("option");
option.appendChild(document.createTextNode(results[i].firstChild.nodeValue));
option.setAttribute("value",results[i].firstChild.nodeValue);
product.appendChild(option);
}
}
function getSelectedC(selectedId, targetId){
//selectedId为空串表示选中了默认项
clearSubSel(targetId); //清除目标列表及下级列表中的选项
targetSelId = targetId;
req = createXHR();
var title = document.getElementById("productD").value;
document.bussiness.text4.value = title;
req.open("get","ajaxtie1?title="+title,true);
req.onreadystatechange = handleRequestC;
req.send(null);
}
function handleRequestC(){
if(req.readyState == 4){
if(req.status == 200){
updateListC();
}else{
alert("您所请求的页面有异常。");
}
}
}
// 更新列表框中列表项函数
function updateListC() {
var product = document.getElementById("productE");
var doc = new ActiveXObject("MSxml2.DOMDocument");
doc.loadXML(req.responseText);
var results = doc.getElementsByTagName("name");
var option = null;
for(var i = 0; i < results.length; i++) {
var option = document.createElement("option");
option.appendChild(document.createTextNode(results[i].firstChild.nodeValue));
option.setAttribute("value",results[i].firstChild.nodeValue);
product.appendChild(option);
}
}
//清除下级子列表选项
function clearSubSel(targetId) {
var canClear = false; //设置清除开关,初始值为假
for (var i=0; i<selArray.length; i++) { //遍历列表数组
if (selArray[i]==targetId) { //当遍历至目标列表时,打开清除开关
canClear = true;
}
if (canClear) { //从目标列表开始到最下级列表结束,开关始终保持打开
clearOptions(document.getElementById(selArray[i])); //清除该级列表选项
}
}
}
//清除传入的列表节点内所有选项
function clearOptions(selNode) {
selNode.length = 1; //设置列表长度为1,仅保留默认选项
selNode.options[0].selected = true; //选中默认选项
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>发贴一</title>
<style type="text/css">
<!--
.sec_menu {
BORDER-RIGHT: white 1px solid;
BACKGROUND: #d6dff7;
OVERFLOW: hidden;
BORDER-LEFT: white 1px solid;
BORDER-BOTTOM: white 1px solid
}
.STYLE12 {
color: #FF0000;
font-size: 14pt;
font-weight: bold;
}
.STYLE25 {
font-size: 14px;
font-weight: bold;
}
body,td,th {
font-size: 9pt;
}
body {
background-color: #FFFFFF;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.STYLE15 {
font-size: 14px;
color: #0033FF;
}
.STYLE27 {
font-size: 16px;
font-weight: bold;
}
.STYLE30 {
color: #999999;
font-size: 14px;
}
.STYLE31 {
color: #009933
}
#file {
font-size: 12px;
line-height: 150%;
}
-->
</style>
</head>
<body
onload="initSelArray('productA','productB','productC','productD','productE');getZonglei('INIT','productA')">
<table width="941" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td width="337">
<img src="images/index_01.jpg" alt="erer" width="337" height="113" />
</td>
<td width="10">
</td>
<td width="594" valign="top">
<table width="100%" height="98" border="0" align="center"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -