I have a Javascript object with the following format assigned to a javascript variable:
var events =
[
{
"Id":20,
"CustomerId":9,
"CustomerName":"Mark Wikkins",
"Code":"CT6789",
"CustomerDate":"\/Date(1466679600000)\/",
"Levels":[
{
"Id":92,
"Nivel":0,
"Code1":"Sales",
"Code2":null,
"Description":"Customer",
},
{
"Id":94,
"Nivel":0,
"Code1":"Sales",
"Code2":null,
"Description":"Customer",
}
]
},
{
"Id":21,
"CustomerId":14,
"CustomerName":"John Stweart",
"Code":"CT70000",
"CustomerDate":"\/Date(146667970000)\/",
"Levels":[
{
"Id":102,
"Nivel":0,
"Code1":"Jobs",
"Code2":null,
"Description":"Customer",
},
{
"Id":106,
"Nivel":"0",
"Code1":"Commissions",
"Code2":null,
"Description":"Customer",
},
{
"Id":113,
"Nivel":0,
"Code1":"Organizations",
"Code2":null,
"Description":"Customer",
}
]
}
];
And I have a drop down with the following Text and Values
<select name="customers_select" id="customers_select">
<option value="92">Sales</option>
<option value="106">Commisions</option>
<option value="113">Organizations</option>
</select>
If I wanted to get the CustomerDate
upon selecting from the drop down, what would be the best way to do it?
As you can see the values of the select (dropdown) map to a Level Id, but the level is a property of the parent object in the Javascript Object
.
So if I select "Commisions"
from the drop down, i need to evaluate my variable events and obtain the CustomerDate for the second object.
Is there something like I could get the CustomerDate by passing the value of the select from the events Javascript Object
array?.