This article describes how to achieve querystring through JavaScript to obtain get parameters, specific implementation of the following, interested friends can refer to ha, I hope to help you
copy code code as follows:
<div id= "page" >
<select name= "Select1" id= "Select-type" >
<option value= "0" > Please choose </option>
<option value= "1" > Enterprise </option>
<option value= "2" > Products </option>
</select>
</div>
Copy Code code as follows:
QueryString = {
Data: {},
Initial:function () {
var apairs, aTmp;
var querystring = new String (window.location.search);
QueryString = Querystring.substr (1, querystring.length);//remove "?"
Apairs = Querystring.split ("&");
for (var i = 0; i < apairs.length i++) {
ATmp = apairs[i].split ("=");
This.data[atmp[0]] = atmp[1];
}
},
Getvalue:function (key) {
return this.data[key];
}
$ (function () {
//init
querystring.initial ();
var type = Querystring.getvalue ("type");
if (typeof (type)!= "undefined") {
$ ("#select-type"). val (type);
}
$ ("#select-type"). Bind (' Change ', function () {
var row = $ (this). Find ("option:selected"). Val ()
//alert (row);
if (row = = 1)
Location.href = "? type=" + row;
if (row = = 2)
Location.href = "? type=" + row;
});
});