Skip to content
Advertisement

Problem displaying dynamic data in an array in Laravel blade view using Javascript

Working on a Laravel application whereby I have some data in an array. The data is a collection of associative arrays whereby each array has an identity number and a collection of policy codes in it. Am fetching the data and displaying to the blade. In the view I have partitioned in 2 columns (using bootstrap grid system). On the left column (col-md-4) am looping through the variable and displaying the identity number which works fine. On the right column I have a table whereby am supposed to display the respective policy code depending on the state of identity_no.

I want to achieve a functionality whereby when the user clicks or hovers over a particular identity number, the respective policy codes should be displayed on the right column (col-md-8)in the table tbody tag. The same should be repeated for subsequent identity numbers (should only display after the identity number has been clicked or hovered on).

Array collection that is stored in a variable called asm

JavaScript

Layout on the view

JavaScript

Advertisement

Answer

You can do like this(tested on my local and found it working):

JavaScript

Hope it helps 🙂

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement