0
I’m a beginner in Javascript, I don’t know how to display the value qtdeEstoque
of listaTamanhos
. Can someone help me?
alert("Tamanho: " + lista.Value + " / Estoque: " + data[i].qtdeEstoque);
listings:
id
qtdeEstoque
Controller:
if (HttpContext.Request.IsAjaxRequest())
{
return Json(new SelectList(
listaTamanhos,
"id",
"id"), JsonRequestBehavior.AllowGet
);
}
View:
$.getJSON("/produto", { id: id, cor: idSelected }, function (data) {
$.each(data, function (i, lista) {
alert("Tamanho: " + lista.Value + " / Estoque: " + data[i].qtdeEstoque);
});
});
view where? you already have some table and want to fill it? you want to create one from scratch?
– Guilherme Lautert
Guilherme, I would like to display the qtyThis message in a Javascript message. It is in a list, already comes from the table.
– Lucas
var listTamanhos = size.Listbyproduct(id); I don’t know how to access the qtyThis attribute is from this list in Javascript. I am returning via Json Return Json(new Selectlist( listSize, "id", "id"), Jsonrequestbehavior.Allowget );
– Lucas
Note that you are with
(new SelectList(listaTamanhos, "id", "id"), JsonRequestBehavior.AllowGet);
would not be(new SelectList(listaTamanhos, "id",
"qtyTech"), JsonRequestBehavior.AllowGet);
?– Guilherme Lautert
You came to debug and see if there is
data[i].qtdeEstoque
because for what you said no.– Guilherme Lautert
would not be, return (new Selectlist(listTamanhos, "id", "id"), Jsonrequestbehavior.Allowget), because I will mount in html a select in html. And the ID is the value that is the same as the DESCRIPTION. See: <select id="size" class="input-validation-error" data-val="true" data-val-required="Select the size" name="size"> <option value=""">-Select the size-</option> <option value="35/36" >35/36</option> <option value="37/38" >37/38</option> <option value="39/40" >39/40</option> </sel
– Lucas
need to access the first parameter of the Selectlist method(listTexts, "id", "id").... listTexts that have the qtyText attribute
– Lucas
in Visual Studio I don’t know how to debug Javascript code, only in Controller and View C#codes. I saw in debug that the attribute qtyText of the listTexts is being filled correctly in the Controller. Now I am missing in Javascript. Only I need that code I posted.
– Lucas