为了账号安全,请及时绑定邮箱和手机立即绑定

通过getjson查询json包中的数据,然后将包中的数据填写到table里

通过getjson查询json包中的数据,然后将包中的数据填写到table里

键入框input    submit键提交,结果执行functiongetjson读取json包中的数据while do 对键入框的信息与json的信息比对,比对成功后将json包中的数据填写到table中的对应位置。思路是这样,求大神告诉怎么能将键入信息和json的对象名进行比较,怎么填表demo.html:<!DOCTYPE html> <html> <head>     <meta charset="utf-8">     <title>demo</title> </head> <body>     <div>             <input type="text" name="txtCount"/>         <input type="submit" name = "Submit" value="Go!" onclick="function()"/>     </div>     <div id="myForm">         <table>             <thead>                 <tr>                     <th>类目</th>                     <th>数据</th>                 </tr>             </thead>             <tbody>                 <tr>                     <td>1</td>                     <td></td>                 </tr>                 <tr>                     <td>2</td>                     <td></td>                 </tr>                 <tr>                     <td>3</td>                     <td></td>                 </tr>                 <tr>                     <td>4</td>                     <td></td>                 </tr>                 <tr>                     <td>5</td>                     <td></td>                 </tr>                 <tr>                     <td>6</td>                     <td></td>                 </tr>                 <tr>                     <td>7</td>                     <td></td>                 </tr>                 <tr>                     <td>8</td>                     <td></td>                 </tr>                 <tr>                     <td>9</td>                     <td></td>                 </tr>                 <tr>                     <td>10</td>                     <td></td>                 </tr>                                             </tbody>         </table>     </div>           <script type="text/javascript">         function SreachBlock(){             $.getJSON('BlockDataObject.json').done(function (data) {                     var    h = document.myForm.txtCount.value;                 while(h == "json包中的对象名"){                     //输出表格内该对象对应的对象数据             });         }     </script> </body> </html>BlockDataObject.json:[     1: {         "1": "lala",         "2": "a",         "3": "b",         "4": "c",         "5": "d",         "6": "e",         "7": "f",         "8": "g",         "9": "h",         "10": "i"     },     2: {         "1": "nana",         "2": "q",         "3": "w",         "4": "e",         "5": "r",         "6": "t",         "7": "y",         "8": "u",         "9": "i",         "10": "o"     },     3: {         "1": "kaka",         "2": "z",         "3": "x",         "4": "c",         "5": "v",         "6": "b",         "7": "n",         "8": "m",         "9": "l",         "10": "k"     } ]
查看完整描述

1 回答

已采纳
?
橋本奈奈未

TA贡献436条经验 获得超108个赞

obj.hasOwnProperty(prop) 方法会返回一个布尔值,指示对象是否具有指定的属性作为自身(不继承)属性。

查看完整回答
反对 回复 2017-08-11
  • 1 回答
  • 0 关注
  • 1788 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信