8.7w+
社区成员
<form aciton="../php/register.php" method="post">
<p>
<label style="color: #ffffff;width: 40%;text-align: right;">所 在 省:</label>
<select style="width:75%;" id="s_province" name="s_province" onchange="setVal1(this.options[this.selectedIndex].text)"></select>
</p>
<p>
<label style="color: #ffffff;width: 40%;text-align: right;">所 在 市:</label>
<select style="width:75%;" id="s_city" name="s_city" onchange="setVal2(this.options[this.selectedIndex].text)"></select>
</p>
<p>
<label style="color: #ffffff;width: 40%;text-align: right;">所 在 县:</label>
<select style="width:75%;" id="s_county" name="s_county" onchange="setVal3(this.options[this.selectedIndex].text)"></select>
</p>
<input type="hidden" id="shengText" value="" name="shengText"/>
<input type="hidden" id="xianText" value="" name="xianText"/>
<input type="hidden" id="shiText" value="" name="shiText"/>
<script class="resources library" src="http://sandbox.runjs.cn/uploads/rs/267/g3ugugjp/area.js" type="text/javascript"></script>
<script type="text/javascript">_init_area();</script>
<p><button type="submit" class="button1">注 册</button>
</p>
</form>
</div>
</body>
<script type="text/javascript">
var Gid = document.getElementById ;
var showArea = function(){
Gid('show').innerHTML = "<h3>省" + Gid('s_province').value + " - 市" +
Gid('s_city').value + " - 县/区" +
Gid('s_county').value + "</h3>"
}
Gid('s_county').setAttribute('onchange','showArea()');
</script>
<script language="javascript">
function setVal1(_text)
{
document.getElementById("shengText").value=_text;
}
function setVal2(_text)
{
document.getElementById("shiText").value=_text;
}
function setVal3(_text)
{
document.getElementById("xianText").value=_text;
}
</script>
var s=["s_province","s_city","s_county"];//三个select的name
var opt0 = ["省份","地级市","市、县级市"];//初始值
function _init_area(){ //初始化函数
for(i=0;i<s.length-1;i++){
document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
}
change(0);
}
还有这一段
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]);
}//end for
if(v){ options[0].selected = true; }
}
}//end if v
if(++v<s.length){change(v);}
}//End with
}
var dsy = new Dsy();
dsy 里面存的是 省市县 的数据,数据量比较大,我就不放出来了。
js脚本是这样的