我有這個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個數據(屬性)中的 –