Two cascading forms using code

Source: Internet
Author: User
Keywords Web page production Ajax javascript
Tags ajax change code content document function game html

<html>
<head>
<title></title>
<meta http-equiv= "Content-type" content= "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", ["Sport", "Music", "Game", "Film and Television", "Model", "anime", "reading", "Hot topic", "Pet"]);

Dsy.add ("0_0", ["Ball Game", "Non ball Games", "other"]);
Dsy.add ("0_1", ["Pop music", "Non pop music", "other"]);
Dsy.add ("0_2", ["Network Game", "Single Game", "other"]);
Dsy.add ("0_3", ["film", "drama", "Other"]);
Dsy.add ("0_4", ["Anime Model", "film Model", "other"]);
Dsy.add ("0_5", ["Anime", "Comics", "Other"]);
Dsy.add ("0_6", ["Books", "Newspapers", "magazines", "Other"]);
Dsy.add ("0_7", ["Spoof Class", "Fashion Class", "other"]);
Dsy.add ("0_8", ["Living Pet", "other"]);
-->
</SCRIPT>
<script LANGUAGE = javascript>


var s=["S1", "S2"];
var opt0 = [Please select, select];
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>
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.