8.18一路向北

2021/8/18 23:12:17

本文主要是介绍8.18一路向北,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

关于今天学了新添加这件事

在框架搭好以后添加

先写前台页面和之前的差不多的那种

 

 差不都就是上面这个鸭子

然后获取值调用自己写的关于数据库储存就可以了

可以用强类型或Ajax或vue

ajax

<script>
$(function () {
GetSheng()
})
function GetAdd() {
var name = $("#name").val();
var leibei = $("[name=leibie]:checked").val();
var sheng = $("#sheng").val();
var shi = $("#shi").val();
var etime = $("#eTime").val();
var price = $("#price").val();
if (name == '') {
return
}
else {
$("#namepsan").hide();
}
if (etime == '') {
return
}
else {
$("#etimespan").hide();
}
if (price == '') {
return
}
else {
$("#pricespan").hide();
}
$.post('http://localhost:9836/api/Values/GetAdd', {
eName: name,
eChuFang: leibei,
eSheng: sheng,
eShi: shi,
eTime: etime,
ePrice: price
}, res => {
if (res > 0) {
alert('添加成功');
location.href = 'Index'
}
else {
alert('添加失败')
}
})
}

function GetSheng() {
$.get('http://localhost:9836/api/Values/GetList?type=0', res => {
$(res).each(function () {
$("#sheng").append('<option value="' + this.oId + '">' + this.oName + '</option>');
})
})
}
function GetShi() {
var id = $("#sheng").val();
$("#shi").empty();
$("#shi").append('<option value="">所有</option>');
$.get('http://localhost:9836/api/Values/GetList?type=' + id, res => {
$(res).each(function () {
$("#shi").append('<option value="' + this.oId + '">' + this.oName + '</option>');
})
})
}

</script>



这篇关于8.18一路向北的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程