1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| //storeid这个下拉框类添加一个change的动作 $('#storeid').on("change", function () { showUseDeviceType($(this).val()); //通过$(this).val()取得storeid的值 }); //定义showUseDeviceType function showUseDeviceType(flag) { var id = "{$id}"; if (id == "") { $.post("{php echo webUrl('share/tationedshoppost')}", {"storeid": flag, "op": "getdevicetype"}, function (data) { $("#device_type_id").html('<option value="0">--空--</option>'); if (data.status == "1") { $.each(data.result, function (i, o) { if (o != undefined && o.id > 0) { $("#device_type_id").append("<option value='" + o.id + "'>" + o.device_name + "</option>"); } }); } }, 'json'); }else { $.post("{php echo webUrl('share/tationedshoppost')}", {"storeid": flag, "op": "getdevicetype","model_number":"{$item['model_number']}"}, function (data) { $("#device_type_id").html('<option value="0">--空--</option>'); if (data.status == "1") { $.each(data.result, function (i, o) { if (o != undefined && o.id > 0) { var option_text = o.device_name; if(o.storeid == 0){ option_text += " --平台"; } $("#device_type_id").append("<option value='" + o.id + "'>" + option_text + "</option>"); } }); $("#device_type_id").find("option[value='{$item['device_type_id']}']").attr("selected",true); } }, 'json'); } } showUseDeviceType($('#storeid').val());
|