键入框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"
}
]
添加回答
举报
0/150
提交
取消