This question was admittedly difficult to word. So I have a twig file. To that file I have sent an array (I am using Symfony 2). In the twig file I loop through the array like so:
{% for i in 0..numberOfCustomerRecords %}
<option value="{{ i }}">{{ customerRecords[i].cardType }} ending in {{ customerRecords[i].last4 }} Exp: {{ customerRecords[i].expirationMonth }}/{{ customerRecords[i].expirationYear }}</option>
{% endfor %}
That is of course in a select form field. You can see there that I've used 'i' in the for loop, to go cycle through the array, as well as populate the value tag of each option to correspond with the index of the customerRecords array.
Now I have some jquery, and basically what I want to do is get the value of the select box, and use that value as the index of the customerRecords array. Something like: {{ customerRecords[$('#customerRecords').val();] }}
Obviously that won't work. But is there a way to do that?