You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/projects/IoTNode/Areas/Admin/Views/Shared/_Script.cshtml

24 lines
756 B

<script>
function clear() {
for (var i = 0; i < arguments.length; i++) {
$(arguments[i]).find('option').not('[value=""]').remove();
}
}
function update(url, id) {
$.getJSON(url, function (data) {
$.each(data, function (i, v) {
$(id).append('<option value="' + v.Value + '">' + v.Text + '</option>');
});
});
}
$(function () {
$('#NodeId').change(function () {
var id = $(this).find(':selected').val();
clear('#DeviceId');
if (id) {
var url = '@Url.Action("GetDeviceJson", "Ajax")?parentId=' + encodeURI(id);
update(url,'#DeviceId');
}
});
});
</script>