我有這個數組對象:getelementsbyid
Array
(
[0] => stdClass Object
(
[id] => 1
[name] => a
[cost] => 5
)
[1] => stdClass Object
(
[id] => 2
[name] => kraftmagar
[cost] => 10
)
[2] => stdClass Object
(
[id] => 3
[name] => prepugilistica
[cost] => 20
)
)
我已經把這個數組中form_dropdown(選擇),並創建一個文本框立即獲得選擇挑
echo form_dropdown('rif_corso', $corsi, '', 'onChange="run();" id="corsi"')
$data = array(
'type' => 'text',
'name' => 'tot',
'id' => 'tot',
);
echo form_input($data);
這是JavaScript函數
function run() {
document.getElementById("tot").value = document.getElementById("corsi").value;
}
時選擇的變化,我想獲得場命名爲「成本」,而不是下面的記錄
[0] => stdClass Object
(
[cost] => 5 // I want this
)
你的意思是'echo $ yourVariable [0] - > cost;'?! – Rizier123
@ Rizier123是的,我的意思是這個,但在JavaScript –
'arrayName [0] .cost'或'arrayName [0] ['cost']'? – mtizziani