第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

使用用戶輸入顯示 json 值

使用用戶輸入顯示 json 值

元芳怎么了 2023-11-12 15:24:37
我的服務(wù)器上有一個(gè) json 腳本。我有三個(gè)文本字段。<label>Index</label><input type="text" id="index" /><br/><label>Worker#</label><input type="text" id="Worker_ID" /><br/><label>Worker Value</label><input type="text" id="worker_value" /><br/><button onclick="Fetch_Result()">Search</button>我有一個(gè)腳本可以顯示 json 文本的具體值<script>函數(shù) Fetch_Result() {  var index = document.getElementById("index").value;  var Value = document.getElementById("Worker_ID").value;  var x = document.getElementById("worker_value").value;  var settings = {     "async": true,     "crossDomain": true,     "url": "http://www.hotel1.com/Experiment/Api/Json1.php",     "method": "GET"  }  $.ajax(settings).done(function (response) {     response = JSON.parse(response); // the change is here     //console.log(response);     console.log(response[index].x.ID);  });}{    "Worker1": {        "ID :": "1",        "Username": "Tony"    }這是我的 json 文本。我無法要求用戶在文本框中輸入工人編號(hào)。我想知道如何用文本框值替換 x 和 ID。這樣我就不必繼續(xù)為新工人編寫代碼。示例:console.log(response[index].userinput1.userinput2);userinput1 是 Worker 編號(hào),例如:Worker1、Worker2、... userinput2 是 Worker 編號(hào)的值,例如:ID、用戶名、...有人能幫我嗎
查看完整描述

1 回答

?
米琪卡哇伊

TA貢獻(xiàn)1998條經(jīng)驗(yàn) 獲得超6個(gè)贊

我無法添加評(píng)論,因?yàn)槲业姆謹(jǐn)?shù)低于 50。但你可以這樣做:

console.log(response[index][id])
console.log(response[index][username])


查看完整回答
反對(duì) 回復(fù) 2023-11-12
  • 1 回答
  • 0 關(guān)注
  • 137 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)