#All my Modals have the same content..

21 messages · Page 1 of 1 (latest)

graceful sphinx
#

https://codepen.io/popmotion/pen/BdoOya
I have put these modals in my code.
I want different content on each modal but I cant figure out how to do it.

Whatever I input into the <div class="modal"> element shows up in all modals.
Even after I tried to have multiple <div class="modal"> elements, it still takes the input from the first one and applies it to all the modals..
I'm quite a beginner, any help would be great

velvet vine
#

For your models, use the Id attribute. For example:

<div class="modal" id="model-1"></div>

And then access it in your javascript as:

const modal1 = document.getElementById("model-1");
graceful sphinx
#

Thanks for you answer,
I tried that but didnt have success because there are many instances where the word "modal" appears inside the javascript and i dont know which one's to replace. I tried to replace everything but doesnt seem to work

desert axle
#

this codepen is not multiple modals. it's multiple buttons opening the same modal.

graceful sphinx
desert axle
#

"how they appear on the front end" doesn't change the fact that they're the same modal

#

if you want to modify that single modal before displaying it, have at it. but there are not 3 modals to modify.

graceful sphinx
#

why so pressed buddy ?
no I dont want to edit 1 modal, I want 3 different modals for each button

desert axle
#

Then write code with three different modals…

#

nobody's "pressed", I was simply pointing out that the code you've shown does not do what you're saying you want it to do.

graceful sphinx
#

do you see a way in general that this can be achieved ? or is it a dead end within this code?

desert axle
#

who wrote this code?

graceful sphinx
#

its a popmotion codepen

#

which I have integrated inside my website

desert axle
#

you should visit #faq to learn JS instead of just having code generated for you that you don't understand.

you either make multiple modals with unique IDs in HTML or you copy a modal template. either way, you manipulate them via JS.

desert axle
#

no, this server is for learning not for hiring

graceful sphinx
#

really ? everything is about learning ?

#

thats how you pay your bills ?

#

then mb, i just have other things on my mind besides "learning"

desert axle
#

and that's wonderful, most of us do. if you'd like to hire somebody, find the appropriate place to do so. this server is not it.

graceful sphinx
#

i didnt intend to , i just didnt thing it would be a problem since you seem to know the solution