兩級聯表單使用代碼

來源:互聯網
上載者:User
關鍵字 網頁製作 Ajax JavaScript

<html>
<head>
<title></title>
<meta HTTP-equiv="Content-Type" content="text/html; charset=gb2312">

<style>
body,select
{
font-size:9pt;
font-family:Verdana;
}
a
{
color:red;
text-decoration:none;
}
a:hover{
text-decoration:underline;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
function Dsy()
{
this. Items = {};
}
Dsy.prototype.add = function(id,iArray)
{
this. Items[id] = iArray;
}
Dsy.prototype.Exists = function(id)
{
if(typeof(this. Items[id]) == "undefined") return false;
return true;
}

function change(v){
var str="0";
for(i=0;i<v;i++){ str+=("_"+(document.getElementById(s[i]).selectedIndex-1));};
var ss=document.getElementById(s[v]);
with(ss){
length = 0;
options[0]=new Option(opt0[v],opt0[v]);
if(v && document.getElementById(s[v-1]).selectedIndex>0 || !v)
{
if(dsy. Exists(str)){
ar = dsy. Items[str];
for(i=0;i<ar.length;i++)options[length]=new Option(ar[i],ar[i]);
if(v)options[1].selected = true;
}
}
if(++v<s.length){change(v);}
}
}

var dsy = new Dsy();

dsy.add("0",["運動","音樂","遊戲","影視","模型","動漫","閱讀","熱點話題","寵物"]);

dsy.add("0_0",["球類運動","非球類運動","其他"]);
dsy.add("0_1",["流行樂","非流行樂","其他"]);
dsy.add("0_2",["網路遊戲","單機遊戲","其他"]);
dsy.add("0_3",["電影","電視劇","其他"]);
dsy.add("0_4",["動漫模型","電影模型","其他"]);
dsy.add("0_5",["動畫","漫畫","其他"]);
dsy.add("0_6",["書籍","報紙","雜誌","其他"]);
dsy.add("0_7",["惡搞類","時尚類","其他"]);
dsy.add("0_8",["有生命寵物","其他"]);
-->
</SCRIPT>
<SCRIPT LANGUAGE = JavaScript>


var s=["s1","s2"];
var opt0 = ["請選擇","請選擇"];
function setup()
{
for(i=0;i<s.length-1;i++)
document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
change(0);
}
-->
</SCRIPT>
</head>
<body bgcolor="#E0E0E0" onload="setup()">

<form name="frm">
<select id="s1"><option></option></select>
<select id ="s2"><option></option></select>
</form>
</body>
 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.