Description: According to choose different store option, send different ID value, show different product list
var formstr = "{' SupplierId ': ' Supply Chain Enterprise |%-jm-sprt-%|93794498-3 '}";
$.ajax ({
Type: "Post",
DataType: "JSON",
Cache:false,
URL: ".. /.. /.. /webservice/gmall.json ",//submit to general handler request data
Data: "Businesscode=61001001&message=" +encodeuri (FORMSTR). Replace (/\+/g, "%2b"),
Async:false,
Error:function () {
Alert ("Connection error!!!");
Layer.alert ("Data loading failed, please contact the Administrator!") ", 0);
},
Success:function (data) {
var Datajson = Strtojson (data.msg);
var shopname = dataJson.body.gmPage;
if (datajson.head.status== ' 000000 ') {
$.each (Shopname,function (I,item) {
$ ("#store"). Append ("<option id=" "+item.id+" ' value= ' "+item.shoptype+" ' title= ' "+item.name+" > "+item.name+" </option> ");
})
$ ("select"). On (' click ', Function () {
var opt = $ (this). Children (' option:selected ');
var shopid = $ (opt). attr (' id ');
var Shoptype = $ (opt). Val ();
var formstrshop = "{' Shopid ':" +shopid+ ", ' Shoptype ':" +shoptype+ "}";
if ($ ("option"). val () = = ") {
$ ("#tb"). empty ();
}
$.ajax ({
Type: "Post",
DataType: "JSON",
Cache:false,
URL: ".. /.. /.. /webservice/gmall.json ",//submit to general handler request data
Data: "Businesscode=61001003&message=" +encodeuri (formstrshop). Replace (/\+/g, "%2b"),
Async:false,
Error:function () {
Layer.alert ("Data loading failed, please contact the Administrator!") ", 0);
},
Success:function (data) {
var Datajson = Strtojson (data.msg);
var shopname = dataJson.body.gmPage;
if (datajson.head.status== ' 000000 ') {
$.each (Shopname,function (I,item) {
var attributeValue11 = Datajson.body.gmpage[i].attributevalue11;
$ ("#tb"). empty ();
$ ("#tb"). Append ("<tr id= '" +item.id+ ">"
+ "<td><input type= ' checkbox ' value= '" +item.id+ "' name= ' price '/></td> '
+ "<td>" +item.sn+ "</td>"
+ "<td>" +item.name+ "</td>"
+ "<td>" +item.attributevalue11+ "</td>"
+ "<td><input type= ' text ' name= ' discount ' class= ' text ' style= ' width:100px '/></td> '
+ "<td>" +0+ "</td></tr>"
);
})
}
}
});
})
}
}
});
"Simple Example" <select name= "" Id= "" >
<option value= "1" id= "1" >123</option>
<option value= "2" id= "2" >gfg</option>
<option value= "3" id= "3" >ds3</option>
<option value= "4" id= "4" >1fgtr3</option>
<option value= "5" id= "5" >6y3</option>
<option value= "6" id= "6" >1fbnh3</option>
<option value= "7" id= "7" >1vdf3</option>
</select>
<script src= "Jquery-1.8.2.min.js" ></script>
<script>
$ (function () {
$ (' select '). On (' click ', Function () {
$ (this). On (' click ', function () {This step can be omitted without the option of a click event
var $opt = $ (this). Children (' option:selected ');
Console.log ($ ($opt). attr (' ID '), $ ($opt). Val (), $ ($opt). html ());
// })
})
})
</script>
jquery Add options Click event and pass Value