Hello, I searched with dropdownlist in asp.net mvc, but I needed a pop-up in this search.
I couldn't get this popup to work, I'm not getting any errors.
It doesn't interact when I press the button.
When I press the button nothing happens.
How can I solve this error?
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#ddlCountry").on('change', function (e) {
$.ajax({
type: 'GET',
url: "/Cari/Search",
dataType: 'json',
data: { country: $(this).find('option:selected').val() },
success: function (response) {
$('#tblCustomers').hide();
$('#tblCustomers tbody').empty();
$.each(response, function (i, item) {
var STOKADI = item.STOKADI;
var STOKID = item.STOKID;
var RESIM = item.RESIM;
var ALIS = item.ALIS;
var SATIS = item.SATIS;
var MIKTAR = item.MIKTAR;
var rows = "<tr>" +
"<td> <button type='button' class='btn btn-info' data-toggle='modal' data-target='#urunekle_"+item.STOKID+"'>+</button> </td>" +
"<td> <img class='buyutec' src='" + item.RESIM + "' style='width:45px;height:45px' /> " + item.STOKADI + "</td>" +
"<td> Alış: " + item.ALIS + " ₺</td>" +
"<td> Satış: " + item.SATIS + " ₺</td>" +
"<td> Miktar: " + item.MIKTAR + " ₺</td>" +
"</tr>";
$('#tblCustomers tbody').append(rows);
});
$('#tblCustomers').show();
},
error: function () {
}
});
});
});
</script>
<div class="modal" id="urunekle_@c.STOKID">
<div style="width: 70%; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%)" class="modal-dialog" id="urunekle_@c.STOKID">
<div class="modal-content">
<div class="modal-body">
<div class="item">
<label style="color: black">Miktar</label>
<input type="number" name="MIKTAR" id="txtmiktar" class="form-control" value="1" />
<label style="color: black">Fiyat</label>
<input type="text" name="FIYAT" id="txtfiyat" class="form-control" value="@((System.Data.SqlTypes.SqlMoney?)c.SATIS)" />
<input type="text" name="STOKID" id="txtstokid" class="form-control" value="@c.STOKID" hidden />
<input type="text" name="FISID" id="txtfisid" class="form-control" value="@ViewBag.fisid " hidden />
<input type="text" name="FIRMA" id="txtfirma" class="form-control" value="@ViewBag.firma" hidden />
<input type="text" name="CARIID" id="txtcariid" class="form-control" value="@ViewBag.cariid" hidden />
<input type="text" name="PLASIYER" id="txtplasiyer" class="form-control" value="@ViewBag.plasiyer" hidden />
<input type="text" name="TARIH" id="txttarih" value="@DateTime.Today.ToString("dd.MM.yyyy")" class="form-control" hidden />
<br />
<button class="btn btn-info form-control" id="urnek">Ürün Ekle</button>
<br />
<br />
<button style="top: 3px" type="button" class="btn btn-danger form-control" data-dismiss="modal">Kapat</button>
</div>
<script type="text/javascript">
$("body").on("click", "#urnek", function () {
var g = {};
g.MIKTAR = $(this).closest('.item').find("#txtmiktar").val();
g.FIYAT = $(this).closest('.item').find("#txtfiyat").val();
g.STOKID = $(this).closest('.item').find("#txtstokid").val();
g.FIRMA = $(this).closest('.item').find("#txtfirma").val();
g.CARIID = $(this).closest('.item').find("#txtcariid").val();
g.PLASIYER = $(this).closest('.item').find("#txtplasiyer").val();
g.FISID = $(this).closest('.item').find("#txtfisid").val();
g.TARIH = $(this).closest('.item').find("#txttarih").val();
$.ajax({
type: "POST",
url: "/Cari/urunekle",
data: JSON.stringify(g),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
window.location.reload(1);
}
});
});
</script>
</div>
</div>
</div>
</div>