如何分解json值设置到text文本框中
Posted 折腾青春
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何分解json值设置到text文本框中相关的知识,希望对你有一定的参考价值。
<td><input type="text" id="name11"></td> //4设置访问成功返回的操作 xhr.onreadystatechange=function(){ if(xhr.readyState==4){ if(xhr.status==200){ var txt=xhr.responseText; var maps=eval("("+txt+")"); /* document.getElementById("name").value("hexiang"); */这句设置不行。要通过setAtrribute for(var i in maps){//通过定义一个局部变量i遍历获取map里面的所有key值 document.getElementById(i).setAttribute("value",maps[i]); } } } };
以上是关于如何分解json值设置到text文本框中的主要内容,如果未能解决你的问题,请参考以下文章