From the QQ website extracts the pure JS province City three level linkage menu _javascript skill

Source: Internet
Author: User
I found in http://ip.qq.com/'s website has qq own JS province city three level linkage. So I did a bit of research. His interface is as follows:

Why not use the data directly?

The surprise is QQ is to use the reference external JS to achieve three-level linkage. JS as follows: Http://ip.qq.com/js/geo.js

Use the following methods:
Copy Code code as follows:

<! DOCTYPE html>
<title>qq JS Province Urban three-level linkage </title>
<!--data--> of the city and province using QQ directly
<!--
<script type= "Text/javascript" src= "Http://ip.qq.com/js/geo.js" ></script>
-->
<script type= "Text/javascript" src= "Geo.js" ></script>
<body onload= "setup ();p reselect (' Shaanxi province ');p Romptinfo (); >
<form>
<select class= "Select" name= "province" id= "S1" >
<option></option>
</select>
<select class= "Select" Name= "City" id= "S2" >
<option></option>
</select>
<select class= "Select" Name= "Town" id= "S3" >
<option></option>
</select>
<input id= "Address" name= "address" type= "hidden" value= "/>" "
<input onclick= "alert (document.getElementById (' address '). Value); return false; "type=" Submit "value=" Submission "/>
</form>
<script>

This function is required because this function is called every time the address is changed in Geo.js
function Promptinfo ()
{
var address = document.getElementById (' address ');
var S1 = document.getElementById (' s1 ');
var s2 = document.getElementById (' s2 ');
var s3 = document.getElementById (' S3 ');
Address.value = s1.value + S2.value + s3.value;
}

</script>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.