I’ve got a page that has multiple buttons that trigger a modal. In the modal i want to display the value that it gets passed…so lets say in the modal i have a variable called product. But each button on this form within it or not theres a named value of this product…so the idea is that each button will overide it with its own product…
Here is the page im working on, the top two products are the working examples…
my demo example (or desired outcome)
or am i making this too complicated…
It can certainly be done with JS. You already are using some
data attributes in your buttons. You can create one for the value you want to pass to the modal. Then when you click a button, you can detect which button triggered the modal, read its data attribute and pass that value on to a function which renders the modal. Not too complicated if you know what to look at. Familiarize yourself with how to read
data attributes of an element and how to detect which element triggers the modal (hint, look at event handlers for the click event and its event target).
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.