JS looping through JSON dataCategory: JS technology js JQuery2010-12-01 13:5643646 People readComments (5) CollectionReportJsonc
JSON data such as: {"Options": "[{/" text/":/" Wang Jia Wan/",/" value/":/" 9/"},{/" text/":/" Li Jia Wan/",/" Valu
e/":/" 10/"},{/" text/":/" Shao Jia Bay/",/" value/":/" 13/"}]"}
Use JS to write:
[JavaScript]View Plaincopyprint?
- varData=[{name:"a", Age:12},{name:"B", Age:11},{name:"C", Age:13},{name:"D", age:14}];
- for var  O  in data) {
- Alert (o);
- Alert (Data[o]);
- alert (" text: " +data[o].name+ " value: " +data[o].age );
- }
Or
[JavaScript]View Plaincopyprint?
- <script type= " Text/javascript " >&NBSP;&NBSP;
- function text () {
- varjson = {"Options":"[{/"text/":/"Wang Jia Wan/",/"value/":/"9/"},{/"text/":/"Li Jia Wan/",/"value/":/"10/"},{/"text/":/"Shao Jia Bay/",/"value/":/"13/"}]"}
- JSON = eval (json.options)
- for var i=0; i< json.length; i++)
- &NBSP;&NBSP;{&NBSP;&NBSP;
- alert (Json[i].text+" " + json[i].value)
- }
- }
- </script>
JS Loop traversal JSON data classification: JS technology js JQuery 2010-12-01 13:56 43646 people read reviews (5) Favorite report Jsonc JSON data such as: {"options":&quo T [{