JS takes out the values in the JSON array

Source: Internet
Author: User

JS takes out the values in the JSON array
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>js out the values in the JSON array </title>

<body>
<script language= "JavaScript Tutorial" >
var json={"status": 1, "info": "u83b7u53d6u6210u529f", "data": [{"id": "4", "Name": "U77f3u5bb6u5e84", "Information": " U5e02 "," region_id ":" 3 "," type ":" 1 "}]}
var data=json.data;
for (i=0;i<data.length;i++)
{
document.write ("Name:" +data[i].name+ ", Info:" +data[i].information+ ");
}
</script>

This is primarily used for traversing the JSON array value and outputting

<script language= "JavaScript" >
function e ()
{
var json=[{"kl_id": "2", "Kl_title": "Test Date", "Kl_content": "Test Date", "Kl_type": "1", "id": "1"},{"kl_id": "2", "Kl_" Title ":" Test "," kl_content ":" Test "," Kl_type ":" 1 "," id ":" 2 "}]
var str = "";
For (Var one in JSON)
{
for (var key in Json[one])
{
STR + + Json[one][key] + ",";
}
}
Document.form.txtName.value = str;
}
</script>
<form >
<input name= "Txtname" >
</form>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.