Jump to content

Passing the contents of a variable (PHP) to a modal with W3.CSS

Recommended Posts


Is there a way I can pass a variable (or contents thereof) to a modal when it is called, perhaps as part of the onclick? I was looking at the w3.CSS example below:

So that, for instance I could do something like... <p>This  <?PHP echo $name; ?> has registered on $site </p>

Apologies if this is the wrong forum, but I'm using W3.CSS and this example is similar to what I am trying to achieve. My final modal will have a construct similar to:





Each will section will have some variables in...



<!-- Trigger/Open the Modal -->
<button onclick="document.getElementById('id01').style.display='block'"
class="w3-button">Open Modal</button>

<!-- The Modal -->
<div id="id01" class="w3-modal">
  <div class="w3-modal-content">
    <div class="w3-container">
      <span onclick="document.getElementById('id01').style.display='none'" 
      class="w3-button w3-display-topright">&times;</span>
      <p>Some text in the Modal..</p>
      <p>Some text in the Modal..</p>



Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...