How to use XMLHTTP to realize two-level linkage Select
This article introduces the relevant knowledge of "how to use XMLHTTP to achieve two-level connected Select". 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!
Using XMLHTTP. We can achieve a lot of good ideas.
This article. Realize the two-level linkage Select.
The traditional two-level linkage is to send all the data to the client..
Using XMLHTTP. We can return the data we need in real time.
Select.htm
The code is as follows:
Function GetResult (str)
{
/ *
*-GetResult (str)-
* GetResult (str)
* function: send a request through XMLHTTP and return the result.
* parameters: str, string, sending condition.
* instance: GetResult (document.all.userid.value)
* author:wanghr100 (grey bean baby. Net)
* update:2004-5-27 19:02
*-GetResult (str)-
, /
Var oBao = new ActiveXObject ("Microsoft.XMLHTTP")
OBao.open ("POST", "Server.asp?sel=" + str,false)
OBao.send ()
/ / the server-side processing returns a string encoded by escape.
/ / return data through XMLHTTP and start building Select.
BuildSel (unescape (oBao.responseText), document.all.sel2)
}
Function BuildSel (str,sel)
{
/ *
*-BuildSel (str,sel)-
* BuildSel (str,sel)
* function: build Select through str.
* Parameter: str, string, returned by the server. There is a specific structure "string 1, string 2, string 3"
* Parameter: sel, the Select to be built
* instance: BuildSel (unescape (oBao.responseText), document.all.sel2)
* author:wanghr100 (grey bean baby. Net)
* update:2004-5-27 19:02
*-BuildSel (str,sel)-
, /
/ / clear the original data first.
Sel.options.length=0
Var arrstr = new Array ()
Arrstr = str.split (",")
/ / start building a new Select.
For (var iTuno Bandi)