Thursday, 20 March 2008

Simple JSon Example

<html>
<head>
<title>JSON test</title>

</head>
<body>

<select id="sel">
</select>

<script type="text/javascript">
var cafe = {"cafelist" : [
{"name" : "aaaaaa", "clubid" : "11111111"},
{"name" : "bbbbbbb", "clubid" : "2222222"},
{"name" : "CCC", "clubid" : 123213213}
]
};

for (var i=0; i<cafe.cafelist.length; i++)
{
//alert(cafe.cafelist[i].name + "," + cafe.cafelist[i].clubid);
var s = document.getElementById("sel");
s.options.add(new Option(cafe.cafelist[i].name, cafe.cafelist[i].clubid),i);
}
</script>
</body>
</html>

No comments: