Hi,
If you want to get the selected data go the below code instead of index,
el_cont = wdevent->get_context_element( 'CONTEXT_ELEMENT').
Now click on el_cont while debugging you will get the index of clicked field. Then you can do as usual.
Hope this will helpful to you.
Regards,
John.