Home > Backend Development > PHP Tutorial > Personally, I prefer to use province-city linkage.

Personally, I prefer to use province-city linkage.

WBOY
Release: 2016-07-29 09:00:25
Original
1085 people have browsed it

This is using the js used by the QQ website to achieve three-level linkage between provinces and municipalities. Quoting is very convenient

Front desk:

<!DOCTYPE html>
<html>
<head>
<title>QQ JS省市区三级联动</title>
<!-- 直接使用QQ的省市区数据 -->
<!--
<script type=<span>"</span><span>text/javascript</span><span>"</span> src=<span>"</span><span>http://ip.qq.com/js/geo.js</span><span>"</span>></script>
-->
<script type=<span>"</span><span>text/javascript</span><span>"</span> src=<span>"</span><span>geo.js</span><span>"</span>></script>
</head>
<body >"</span><span>setup();preselect('陕西省');promptinfo();</span><span>"</span>>
        <form>
            <<span>select</span><span>class</span>=<span>"</span><span>select</span><span>"</span> name=<span>"</span><span>province</span><span>"</span> id=<span>"</span><span>s1</span><span>"</span>>
              <option></option>
            </<span>select</span>>
            <<span>select</span><span>class</span>=<span>"</span><span>select</span><span>"</span> name=<span>"</span><span>city</span><span>"</span> id=<span>"</span><span>s2</span><span>"</span>>
              <option></option>
            </<span>select</span>>
            <<span>select</span><span>class</span>=<span>"</span><span>select</span><span>"</span> name=<span>"</span><span>town</span><span>"</span> id=<span>"</span><span>s3</span><span>"</span>>
              <option></option>
            </<span>select</span>>
            <input id=<span>"</span><span>address</span><span>"</span> name=<span>"</span><span>address</span><span>"</span> type=<span>"</span><span>hidden</span><span>"</span> value=<span>""</span> />
          <input >"</span><span>alert(document.getElementById('address').value); return false;</span><span>"</span> type=<span>"</span><span>submit</span><span>"</span> value=<span>"</span><span>提交</span><span>"</span> />
        </form>
<script>

<span>//</span><span>这个函数是必须的,因为在geo.js里每次更改地址时会调用此函数</span><span>function promptinfo()
{
    </span><span>var</span> address = document.getElementById(<span>'</span><span>address</span><span>'</span><span>);
    </span><span>var</span> s1 = document.getElementById(<span>'</span><span>s1</span><span>'</span><span>);
    </span><span>var</span> s2 = document.getElementById(<span>'</span><span>s2</span><span>'</span><span>);
    </span><span>var</span> s3 = document.getElementById(<span>'</span><span>s3</span><span>'</span><span>);
    address.value </span>= s1.value + s2.value +<span> s3.value;
}

</span></script>
</body>
</html>
Copy after login

The backend uses js.

Instance download: http://files.cnblogs.com/zjfree/qqJsAddress.rar

Original link: http://www.cnblogs.com/zjfree/

The above introduces the province and city linkage that I personally like to use, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template