So I have a javascript function call in php onChange and it uses json_encode to convert array so I can send it as javascript function parameter.
json_encode:
Code
[{"Id":8,"Mp":1301},{"Id":9,"Mp":1301},{"Id":3,"Mp":1301},{"Id":2,"Mp":1301},{"Id":4,"Mp":0},{"Id":10,"Mp":1315},{"Id":7,"Mp":0},{"Id":6,"Mp":0},{"Id":1,"Mp":0},{"Id":5,"Mp":0}]
javascript:
Code
function function_to_call(array){
//action I need to do
}
In javascript I need to be able to handle the array so I can pick up Mp value for specific Id. Example for Id 10 I want to alert the 1315. But so far when I try to alert the array alone it only gives output:
Code
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
I also tried using
Code
for(key in array){alert(array[key])}
Which alerts [object Object] for each {Id,Mp} set, how I can get out the Id value and Mp value?
Not really familiart with JS so pretty clueless how to do this, any suggestions how could I get this to work?