当前位置: 代码迷 >> JavaScript >> JS如何用onclick选定下拉菜单中的某一项啊
  详细解决方案

JS如何用onclick选定下拉菜单中的某一项啊

热度:162   发布时间:2012-06-25 18:37:39.0
JS怎么用onclick选定下拉菜单中的某一项啊?
贴个代码.就是想加个功能.按"当前地址"按钮的时候。下来菜单也跟着跳到相对应的选项..选项对应当前的IP地址



HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>久久家具网</title>
<script type="text/javascript" src="./jquery-1.7.min.js"></script>
<script type="text/javascript" src="./select.js"></script>
<script language="JavaScript"    type="text/javascript" src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js"></script>
</head>


<body>
<select name="selectProvince" id="s_province">
    <option>下拉省</option>
    </select>
<select name="selectCity" id="s_city">
    <option>下拉市</option>
    </select>
<select name="selectCounty" id="s_county">
    <option>下拉区</option>
    </select>
    
<script type="text/javascript">
    $(function () {
        $("#s_province").ProCity("s_city", "s_county");
    });
</SCRIPT>
<input type="button" value="确定" onclick="checkit()">
<input type="button" value="当前地址" onclick="nowplace()">
<script type="text/javascript">
function checkit () {
    if ($("#s_province option[value=" + $("#s_province").val() + "]").text()==="请选择"){
        alert("请选择省份")
        }
    else if($("#s_city option[value=" + $("#s_city").val() + "]").text()==="请选择"){
        alert("请选择市")
        }
    else{
        alert("省:" + $("#s_province option[value=" + $("#s_province").val() + "]").text() + "\n" +"市:" + $("#s_city option[value=" + $("#s_city").val() + "]").text()+"\n" +"区:"+$("#s_county option[value=" + $("#s_county").val() + "]").text())
    alert("市:" + change(s1))
    }
}

function nowplace () {
        alert("省:" + remote_ip_info.province + "\n" +"市:" + remote_ip_info.city +"\n" +"区:"+remote_ip_info.district )
    }

alert("\n"+ "\n"+ "您的IP:" + remote_ip_info.start + "\n" +  "所属国家:" + remote_ip_info.country + 
"\n" +    "所属省:" + remote_ip_info.province  + "\n" +  "所属市:"  +remote_ip_info.city +   "\n"   +"所属区:"  +remote_ip_info.district   +
"\n" +    "isp: "   +remote_ip_info.isp   + "\n" +  "type:"    +remote_ip_info.type +"\n" +"desc:" +    remote_ip_info.desc   );
</script>
<script language="JavaScript"    type="text/javascript" src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js"></script>
<script src="./provinceCity.js" type="text/javascript"></script>
</body>
</html>


贴个JS文件的地址:http://www.jia99.com//webconfig/jia99/101/TPL/default/js/provinceCity.js


------解决方案--------------------
alert("省:" + remote_ip_info.province + "\n" +"市:" + remote_ip_info.city +"\n" +"区:"+remote_ip_info.district )
既然你获得了这些值。。直接传过去呗。。
  相关解决方案