Please answer me as example Select code
- I want to add values into array local file JSON (insert member to JSON)
- element is also replaced my element like
type,name... in JSON (update member in JSON) - delete number line where
id="1"andemail="[email protected]"(delete memebr in JSON)
JSON file : report.json
var amir='{"reports":[' +
'{"id": "1","type": "admin","name": "amir","email": "[email protected]","password": "123"},' +
'{"id": "2","type": "member","name": "kevin","email": "[email protected]","password": "1234"}]}';
example select code for check register admin :
var obj = JSON.parse(amir);
for(c = 0; c <= obj.reports.length - 1; c++) {
type = obj.reports[c].type.toString();
if (type == "admin") {
active = 1;
}
if (c == obj.reports.length - 1) {
if (active == 1)
alert("Yes");
else
alert("No");
}
}
@user1011278with syntax code in html :<script src="javascript/report.json"></script>