c# - json index checking and reaching values -
var jsonadim = []; function openmodal(index) { $("#<%= hidinputsenaryoindex.clientid %>").val(index); $("#senaryoadimtable tbody").html(""); jsonadim = $("#<%= hidinputsenaryoadim.clientid %>").val(); console.log(jsonadim); (i = 0; < jsonadim.length; i++) { console.log(jsonadim[i]["index"] + " -- " + index); if (jsonadim[i]["index"] == index + "") { var tr = "<tr><td>" + jsonadim[i]["x"] + "</td><td>" + jsonadim[i]["y"] + "</td></tr>"; $("#senaryoadimtable tbody").append(tr); } } }
i console >
[{"index":"1","x":"0","y":"a1"},{"index":"1","x":"0","y":"a2"}] undefined -- 1
question >
how can reach json? > jsonadim[i]["index"]
looks contained in jsonadim json string, try using json.parse objects out string follows: jsonadimparsed = json.parse(jsonadim);
check out how use json.parse here
Comments
Post a Comment