Skip to content
Advertisement

Turn 2 dimensional excel table to filtered dropdown

Can you help me figure out how to turn this table below into a filtered dropdown using reactjs. I need to filter the result by age ( let’s say the user is 33 years old) and show him the available options for his age group ( Capital to cover and monthly premium related to it ) then catch the data selected.

here is what I have accomplished so far:

1 – Turn the Excel table to CSV then using this website https://shancarter.github.io/mr-data-converter/ I changed it to JSON ARRAY. Here is a snippet of the result :

JavaScript

2 – calculate the Age from birthdate then connect a function to identify the category to which the user belongs to. Note what I call Index is the index of the list item ex: [“111.000 €”,”25 €”,”27 €”,”28 €”,”31 €”,”34 €” ] the list starts at 0 , 1, 2 … corresponding to the column on the excel sheet.

JavaScript

3- I Use forEach to get separate items from the main list and generate a new list with only the parameters matching the index value.

JavaScript

This is where I am hitting a little snag for some reason the state value only shows the last item ( it’s like the list is not getting populated )

Any thoughts?

Life_Insurance_price_table.jpg

Advertisement

Answer

Final view

On my second reading I realised what you wanted to archive.
Here is my solution.
Here is the environment.

JavaScript
Advertisement