我有这个JSONObject。根据密钥从JSONObject获取数据
{
"headerContent": [
{
"name": "User Id",
"key": "userId",
"type": "text",
"default": "Enter User Id"
},
{
"name": "User Name",
"key": "userName",
"type": "text",
"default": "Enter User Name"
},
{
"name": "Password",
"key": "password",
"type": "password",
"default": "Enter Password"
},
{
"name": "Mobile Number",
"key": "mobileNumber",
"type": "text",
"default": "Enter Mobile Number"
},
{
"name": "User Category",
"key": "userCategory",
"type": "select",
"default": "Select Category",
"options" : ["Admin", "Client", "Regulator"]
},
{
"name": "E-Mail",
"key": "email",
"type": "text",
"default": "Enter Email"
},
{
"name": "User Access",
"key": "userAccess",
"type": "select",
"default": "Select User Access",
"options" : ["All", "Site"]
}
],
"bodyContent": [
{
"userId": "user_1",
"userName": "DemoUser",
"mobileNumber": "99999999",
"userCategory" : "Admin",
"email" : "[email protected]",
"userAccess" : "All"
}
]
}
的headerContent
描述的bodyContent
属性。 现在,默认情况下,对象(如user_1)中的所有数据将显示在details
。在html页面中,我有一个包含3个值Admin,Client,Regulator的选择框;这是3种不同的用户类别。当我选择其中的任何一个时,我想用userCatagory =“Admin”显示数据。
我的HTML页面包含一个选择框来选择类别。
<script src="JSCode.js"></script>
<table align='center' >
<tr>
<td> <select id='listSelect' onChange="updateList()">
<option value='' selected >All</option>
<option value='admin'>Admin</option>
<option value='client'>Client</option>
<option value='regulator'>Regulator</option>
</select></td>
</tr>
<tr>
<td> <p id='details'> </P> </td>
</tr>
</table>
当选择选项发生变化时,details
中的内容应相应更改。
后你'html'太 – ozil
置HTML,也别说你已经尝试过的事情。 –
**当我选择其中的任何一个时,我想用userCatagory =“Admin”显示数据。**其中是Admin类别的数据?在'headerContent'中检查第5个数据(属性)中的 –