<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Test</title>
<style>
.item{
width:100px;
height:40px;
border:1px solid #333;
}
.item_sel{
width:100px;
height:40px;
background-color:#09F;
border:1px solid #03C;
}
</style>
<script>
function change(n){
document.getElementById("s1").className = 'item';
document.getElementById("s2").className = 'item';
document.getElementById("s"+n).className = 'item_sel';

document.getElementById("d1").style.display = "none";
document.getElementById("d2").style.display = "none";
document.getElementById("d"+n).style.display = "";
}
</script>
</head>
<body>
<span class="item_sel" id="s1" onClick="change(1)">国内</span><span class="item" id="s2" onClick="change(2)">国外</span>
<div id="d1">
<select>
     <option>广州</option>
        <option>北京</option>
        <option>上海</option>
    </select>
</div>
<div id="d2" style="display:none">
<select>
     <option>纽约</option>
        <option>伦敦</option>
        <option>墨尔本</option>
    </select>
</div>
</body>
</html>

解决方案 »

  1.   

    jquery有这样的写好的框架,你自己去找一找,大体意思就是在文本框下面有个div 用来保存你上面文本上输入的值 从数据库查询的值
      

  2.   

    我把我以前写的一个贴出来了,包括2900多个国内城市,国际城市你自己搜集一下就可以了。全部保存在js文件中
    如果只要地级市,js文件其实很小。http://www.entiweb.com/share.htm请不要删除js文件中的版权申明
      

  3.   

    数组能解决,为什么非要ajax?在本地多快,ajax终归是不可靠的,这个也加一个进度条吗