<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
var jsonList =
{
"dropdownlist":
[
{ "id": "2", "name": "Delhi" },
{ "id": "3", "name": "UP" },
{ "id": "4", "name": "MP" },
{ "id": "5", "name": "AP" }
]
}
$(document).ready(function ()
{
$.each(jsonList.dropdownlist, function (data, value)
{
$("#DLState").append($("<option></option>").val(value.id).html(value.name));
});
});
</script>
</head>
<body>
<select id="DLState">
</select>
</body>
</html>
So, we have learned how we can bind dropdown using JSON, If you have any doubt, please feel free to comment below.
Post a Comment