Converting a JSON array from a PHP array by json_encode. I want to find the index of a specific element from that JSON array by JavaScript/JQuery.
First the user will select a option where the values will be the IDs of people.
<select class="form-control" id="pname" name="pname" required>
<option value="">--Please select--</option>
<option value="312">John Doe</option>
<option value="313">Mark Angel</option>
<option value="314">Chloe Karl</option>
</select>
Then by JavaScript/JQuery I need to get the index of the value of selected option from the JSON array given below.
{
"p_id":{"1":312,"2":313,"3":314},
"p_name":{"1":"John Doe","2":"Mark Angel","3":"Chloe Karl"},
"p_dob":{"1":"1983","2":"1993","3":"1987"},
"p_sex":{"1":"Male","2":"Male","3":"Male"}
}
[ ]in javascript.