Three-Level linkage menu of pure JS province, city, and district extracted from QQ website

Source: Internet
Author: User

I found that there is QQ own JS province/city level 3 linkage in the http://ip.qq.com/website. So I studied it. The interface is as follows:
 
Why not directly use the data?

The surprise is that QQ uses external JS references to achieve three-level linkage. JS is as follows: http://ip.qq.com/js/geo.js

The usage is as follows:
Copy codeThe Code is as follows:
<! DOCTYPE html>
<Html>
<Head>
<Title> qq js provincial/municipal level-3 linkage </title>
<! -- Directly use QQ's provincial and municipal data -->
<! --
<Script type = "text/javascript" src = "http://ip.qq.com/js/geo.js"> </script>
-->
<Script type = "text/javascript" src = "geo. js"> </script>
</Head>
<Body onload = "setup (); preselect ('shaanxi province '); promptinfo ();">
<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 = "submit"/>
</Form>
<Script>

// This function is required because it 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>
</Html>

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.