Skip to content
Advertisement

Displaying the clicked value (link) on a page in a modal window together with the index value

I have a page with some values in a table which are read from a .csv file and displayed. The values changes with time (dynamic), So I am using for loop in PHP with the size of the file as limit of loop and displaying the values and each values are links that displays a modal window when clicked.

This is my code:

JavaScript

The modal window should contain the respective color clicked, the index and a field for brightness.

And I have a css for overlay where the field is hidden initially,

My csv file is:

green, red, white, blue, yellow

When the button (link) with these values are clicked, it will show a modal window, but it is always showing the first value for all buttons (green always) with index value as 0. Am I doing wrong somewhere? Should I use some JavaScript for obtaining this functionality?

(I am not supposed to use jQuery anywhere)

Advertisement

Answer

you can use only one ID on your page, as i see you have lots of id=”overlay”, that’s why it opens the first one

make your id like overlay + Index, and path this name as a parameter to your onclick=”overlay(overlay + Index)

Advertisement