三级联动完整代码出现错误!200分送! 很急!!!!!!!!!!!11谢谢了!

cenpy 2005-05-15 05:41:25
这个是完整的代码!基本功能已经写好了!还差三级联结那里出现问题!2级选择了后,3级没任何反应!而且最后的提示窗口中不能提取2、3级的数据!希望谁能帮帮我??
真的很急!!谢谢!

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
.style1 {
font-size: 24px;
font-weight: bold;
}
.style5 {font-size: 18px}
-->
</style>
</head>
<SCRIPT>
//(c)2000 Webteacher Software, LLC
//http://www.webteacher.com

platform=window.navigator.appVersion;
ie3=0;
if (platform.indexOf('MSIE 3')>0) {
ie3=1;
}

triphop=new Array()
triphop[0]="masstiveattack";
triphop[1]="potishead";

jpop=new Array()
jpop[0]="LovePsychedelicot";

RB=new Array()
RB[0]="thecardigans";
RB[1]="natalieimbruglia";



thecardigans=new Array()
thecardigans[0]="Emmerdale";
thecardigans[1]="Life";
thecardigans[2]="First Band On The Moon";
thecardigans[3]="Gran Turismo";
thecardigans[4]="Long Gone Before Daylight";
thecardigans[5]="Other Side of the Moon";
thecardigans[6]="Long Gone Before Daylight";
thecardigans[7]="Long Gone Before Daylight";

natalieimbruglia=new Array()
natalieimbruglia[0]="Left Of The Middle";
natalieimbruglia[1]="White Lilies Island";


potishead=new Array()
potishead[0]="potishead";
potishead[1]="bloom";

massiveattack=new Array()
massiveattack[0]="Singles 90/98";
massiveattack[1]="Mezzanine";
massiveattack[2]="100th windows";
massiveattack[3]="Formica Blue";

LovePsychedelico=new Array()
LovePsychedelico[0]="Early Times";

function setList(f) {
if (ie3) {
alert('Changable lists do not work with Internet Explorer 3');
return;
};
secondlist=eval(f.list1.options[f.list1.selectedIndex].value);
f.list2.options.length=0;
for(i=0;i<secondlist.length;i++) {
f.list2.options[i]=new Option(secondlist[i]);
};
f.list2.selectedIndex=0;
};

function setList2(f) {
if (ie3) {
alert('Changable lists do not work with Internet Explorer 3');
return;
};
secondlist2=eval(f.list2.options[f.list2.selectedIndex].value);
f.list3.options.length=0;
for(i=0;i<secondlist2.length;i++) {
f.list3.options[i]=new Option(secondlist2[i]);
};
f.list3.selectedIndex=0;
};


function BuySubmit(f)
{
//if(f.yourname.value.length==0){
//alert("Your name can't be ignored!");
//return;}
//if(f.youraddress.value.length==0){
//alert("Your address can't be ignored!");
//return;}
//if(f.yourphone.value.length==0){
//alert("Your phone can't be ignored!");
//return;}
//var SuccessMessage="You have successfully bought "+f.list1.value+"'s"+f.list2.value+" CDS!";
//alert(SuccessMessage);
customerName = prompt('Type your name:',"");
if(customerName.length==0)
{
alert("Your name are incorrect!");
return;
}
customerEmail = prompt('Type your Email:',"");
if(customerEmail.length==0)
{
alert("Your Email are incorrect!");
return;
}
customerAddress = prompt('Type your address:',"");
if(customerAddress.length==0)
{
alert("Your address are incorrect!");
return;
}
customerPhone = prompt('Type your phone:',"");
if(customerPhone.length==0)
{
alert("Your phone are incorrect!");
return;
}
var SuccessMessage="You have successfully bought "+f.list1.value+"'s CDS:"+f.list2.selectedIndex.value;
alert(SuccessMessage);
};
</SCRIPT>
<body>
<p align="center" class="style1">Welcome to nicole's CD shop!</p>
<p> </p>
<p>Choose your CDs:</p>
<FORM NAME="listsform">
<p> </p>
<table width="326" border="0" cellpadding="0" cellspacing="0">
<tr>
<td ><div align="left">Type of music:</div></td>
<td ><select name="list1" onChange="setList(form)">
<option value="triphop">trip-hop</option>
<option value="jpop">j-pop</option>
<option value="RB">R&B</option>
</select></td>
</tr>
<tr>
<td><div align="left">Artist:</div></td>
<td><select name="list2" onChange="setList2(form)">
<option>         </option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
</select></td>
</tr>
<tr>
<td><div align="left">CDs:</div></td>
<td><select name="list3">
<option>         </option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
</select></td>
</tr>
</table>
<p> </p>
<p>
<INPUT type=button value=Buy name=Submit onClick="BuySubmit(form)">
</p>
</FORM>
<p>

</p>
</body>
</html>
...全文
95 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
梅雪香 2005-05-16
  • 打赏
  • 举报
回复
代码挺乱的,看看我这个,简单一些

<html>
<head>
<script language=javascript>
var arr="浙江|江苏|安徽|江西";

var arr0 = "杭州|宁波|温州|绍兴"; //这些数据可以从数据库中取得
var arr1 = "南京|苏州|无锡|常州";
var arr2 = "合肥|翕县|黄山|祁门";
var arr3 = "南昌|九江|赣州|上饶";

var arr00 = "杭州A区|杭州B区";
var arr01 = "宁波A区|宁波B区";
var arr02 = "温州A区|温州B区";
var arr03 = "绍兴A区|绍兴B区";

var arr10 = "南京A区|南京B区";
var arr11 = "苏州A区|苏州B区";
var arr12 = "无锡A区|无锡B区";
var arr13 = "常州A区|常州B区";

var arr20 = "合肥A区|合肥B区";
var arr21 = "翕县A区|翕县B区";
var arr22 = "黄山A区|黄山B区";
var arr23 = "祁门A区|祁门B区";

var arr30 = "南昌A区|南昌B区";
var arr31 = "九江A区|九江B区";
var arr32 = "赣州A区|赣州B区";
var arr33 = "上饶A区|上饶B区";

//alert(eval("arr"+2+1));
function AddOptions(dltObj,arrObj)
{
dltObj.innerHTML="";
var arrLocation=arrObj.split("|");
for(var i=0;i<arrLocation.length;i++){
var opt=document.createElement("OPTION");
dltObj.add(opt);
opt.value=i;
opt.text=arrLocation[i];
}
}
function ShowValue(){
var dltAr=document.getElementById("dltArea");
var hidId=document.getElementById("OutValue");
var txtText=document.getElementById("txtOutText");
hidId.value=dltAr.options[dltAr.selectedIndex].value;
txtText.value=dltAr.options[dltAr.selectedIndex].text;

}
function init(){
AddOptions(dltProvince,eval('arr'));
AddOptions(dltCity,eval('arr'+dltProvince.selectedIndex));
AddOptions(dltArea,eval('arr'+dltProvince.selectedIndex+dltCity.selectedIndex));
ShowValue();
}
</script>
</head>
<body onLoad="init();">
<table width="300" cellpading="0" cellspacing="0" border="2">
<tr>
<td width="100"><select id="dltProvince" onchange="AddOptions(dltCity,eval('arr'+dltProvince.selectedIndex));AddOptions(dltArea,eval('arr'+dltProvince.selectedIndex+dltCity.selectedIndex));ShowValue();" style="width:100%"></select>
</td>
<td width="100"><select id="dltCity" onchange="AddOptions(dltArea,eval('arr'+dltProvince.selectedIndex+dltCity.selectedIndex));ShowValue();" style="width:100%"></select>
</td>
<td width="100"><select id="dltArea" style="width:100%" onchange="ShowValue()"></select></td>
<td width="100">
<input type="hidden" id="OutValue" value="">
<input type="text" id="txtOutText" style="width:100%">
</td>
</tr>
</table>
</body>
</html>
jaden1024 2005-05-16
  • 打赏
  • 举报
回复
secondlist2=eval(f.list2.options[f.list2.selectedIndex].value);
改为:
secondlist2=eval(f.list2.options[f.list2.selectedIndex].text);
showfray 2005-05-16
  • 打赏
  • 举报
回复
你上www.51js.com上面,有大把的这样的程序示例。

千万不要忘了给他我呀。


其实我现在都有,介于是动态的,没有时间改成静态的给你的了。xml有很多个文件。
AgathaZ 2005-05-16
  • 打赏
  • 举报
回复
把secondlist2=eval(f.list2.options[f.list2.selectedIndex].value);
改成
secondlist2=eval(f.list2.options[f.list2.selectedIndex].text);
就ok了
dep_boy 2005-05-16
  • 打赏
  • 举报
回复
//这些数据可以从数据库中取得


怎样读数据库啊!!!!!!!!!!
leo963258 2005-05-15
  • 打赏
  • 举报
回复
当你选第一个事件时候2级改变了。
但是你需要写一个,事件仿真器。
document.all.list2.change()
把这个写进去!!
cenpy 2005-05-15
  • 打赏
  • 举报
回复
天啊!
竟然没人回答!!
急死我了!

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧