Php+javascript realizes three level linkage menu

Source: Internet
Author: User
Tags php tutorial

PHP Tutorial + Web effects to achieve the three-level linkage menu

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title>insert title here</title>
<script type= "Text/javascript" >
<!--
var prov = data.province;
var city = data.city;
var area = Data.area;

function Change (v)
{
var str = 0;
var val = 0;
if (v>0)
{
OBJ = document.getElementById (' s ' +v);
val = obj.options[obj.selectedindex].value;
}

var obj = document.getElementById (S[v]);
With (obj)
{
length = 0;
Options[0] = new Option (Opt0[v],opt0[v]);
var $arr = get (V,val);
for (var key in arr)
{
Options[length] = new Option (Arr[key],key);
if (v && options[1]) options[1].selected = true;
if (++v < s.length) Change (v);
}
}

}

function Get (index, Val)
{
var value = "";
if (index = = 0)
{
value = Prov;
}else if (index = = 1) {
value = City;
}else if (index = = 2) {
Value = Area;
}

var t = new Array ();
if (val = 0)
{
return value;
}else {
For (var k in value)
if (k.substr (0,val.length) = val)
{
T[K] = value[k];
}
return $t;
}

}
var s = ["S1", "S2", "S3"];
var opt0 = ["-Select-Provinces-", "-select-City-", "-select-urban-"];
function Setup ()
{
For ($i =0 $i <s.length-1; $i + +)
{
document.getElementById (S[i]). onchange = new Function ("Change (" + (i+1) +) ");
Change (0);
}
}
-->
</script>
<body onload= "setup ();" >
<select id= "S1" ><option>-choice-Provinces and cities-</option></select>
<select id= "S2" ><option>-choice-City-</option></select>
<select id= "S3" ><option>-choice-Urban-</option></select>

</body>

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.