首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

js省地县三级联动

2012-08-21 
js省市县三级联动头部script languagejavascript typetext/javascriptfunction convert(){var obj

js省市县三级联动

头部

<script language="javascript" type="text/javascript">
    
    function convert(){
var obj = document.getElementById('s1'); //定位id

var index = obj.selectedIndex; // 选中索引

var text = obj.options[index].text; // 选中文本

var obj2 = document.getElementById('s2'); //定位id

var index2 = obj2.selectedIndex; // 选中索引

var text2 = obj2.options[index2].text; // 选中文本
var text3=text+" "+text2+" ";
//alert(text3);
var text4=text;
document.getElementById('PrCi').value=text3;
document.getElementById('PrCi2').value=text4;


}

</script>

头部引入js:

<script type="text/javascript" src="__PUBLIC__/js/upssx.js"></script> ( 有谁需要upssx.js文件,加我qq:977675799,或者在留言中写上您的邮箱,我给您发过去)



body部分:

<!--下面的两个input是省和市,点击提交按钮后会将省市的名称提交到后台,让后台处理-->

<input type="hidden" name="PrCi" id="PrCi"/>
<input type="hidden" name="PrCi2" id="PrCi2"/>

 <select class="guanli_select"   id="s1" name="s1">
                   <option  value="">省份</option>
                 </select>               </td>
               <td width="120"> <select class="guanli_select" id="s2" >
                   <option  value="">地级市</option>
                 </select>
               <td width="390" >

<!--不管用这个id="s3"的select都要写这个select,不然会出错-->

<select class="guanli_select" id="s3" >
                   <option  value="">市,县级市</option>
 </select>

<script type="text/javascript" src="__PUBLIC__/js/downssx.js"></script>   ( 有谁需要downssx.js文件,加我qq:977675799,或者在留言中写上您的邮箱,我给您发过去)


热点排行