Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the two-level linkage between province and city in AJAX drop-down box

Shulou Source: shulou.com Published: 2022-06-03 07:40:56 11月15日 Update

This article introduces the relevant knowledge of "how to achieve the two-level linkage of provinces and cities in the AJAX drop-down box". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Jsp page code:

The copy code is as follows:

Var xmlHttp=null

/ / create a xmlhttprequest object

If (window.XMLHttpRequest) {

XmlHttp=new XMLHttpRequest ()

} else {

XmlHttp=new ActiveObject ("Microsoft.XMLHTTP")

}

Var url= GetProvince?time= + new Date (). GetTime ()

Function getsheng () {

XmlHttp.open ("post", url,true)

XmlHttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded")

XmlHttp.send ()

XmlHttp.onreadystatechange=getprovince

}

Function getprovince () {

If (xmlHttp.readyState==4 & & xmlHttp.status==200) {

Var xmlFile=xmlHttp.responseXML

/ / get the node of the province

Var province=xmlFile.getElementsByTagName ("province")

/ / get the select tag

Var pselect=document.getElementById ("sheng")

/ / cycle to check out the provincial information of the xml file

For (var iTuno Bandi)

Tags: Code utf-8 drop-down information content more knowledge loop utility learning next dilemma reality object situation file article tag case ribbon Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Tech Info Linux Xiaomi MySQL