我有这个数组对象: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