title: Opening modal from dropdown list to add client
body: <p>Linked to my prior post yesterday on how to have a value of a selector change the behaviour of my javascript, I run into trouble opening a modal window. </p>
  
  <p>The idea is that if "add client" is selected from the first dropdown list, instead of dynamically populating the second dropdown list with "projects", a modal window pops-up to allow the user to add a client. </p>
  
  <p>I have index3.php:</p>
  
  <pre><code>&lt;?php
  error_reporting(E_ALL);
  ini_set('display_errors', 1);
  
  include 'dbconnect.php';
  ?&gt;
  
  &lt;script type="text/javascript" src="scripts/jquery-3.1.1.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
  function fetch_select(val)
  {   
    if (val != "add_client")
    {
      $.ajax({
       type: 'post',
       url: 'fetch_data.php',
       data: {
         get_option:val
       },
       success: function (response) {
        document.getElementById("projects").innerHTML=response; 
       } 
      });
    }
    else
    {
      //code to open modal below
      success: function overlay() {
      el = document.getElementById("overlay");
      el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
      }
      //code to open modal above
    }
  }
  &lt;/script&gt;
  
  &lt;?php
  echo "&lt;table&gt;";
  echo "&lt;form action='index3.php method='post'&gt;";
  echo "&lt;tr&gt;";
  echo "&lt;td&gt;";
      echo "&lt;select name='client' id='client' onchange='fetch_select(this.value);'&gt;"; 
      echo "&lt;option&gt;Name of Firm&lt;/option&gt;"; 
      $select = mysqli_query($Verbinding,"SELECT client FROM clients GROUP by client");
      while ($row = mysqli_fetch_array($select)) 
          {
          echo '&lt;option value="'.$row['client'].'"&gt;'.$row['client'].'&lt;/option&gt;';
          }
      echo "&lt;option value='add_client'&gt;Add Client&lt;/option&gt;";
      echo "&lt;/select&gt;";
  echo "&lt;/td&gt;";
  echo "&lt;td&gt;";
      echo "&lt;select name='project' id='projects'&gt;";
      echo "&lt;option&gt;Select Project&lt;/option&gt;";             
      echo "&lt;/select&gt;";
  echo "&lt;/td&gt;";
  echo "&lt;/tr&gt;";
  echo "&lt;/table&gt;";
  echo "&lt;/form&gt;";
  
  echo "&lt;div id='overlay'&gt;";
      echo "&lt;div&gt;";
      echo "&lt;p&gt;Content of modal window.&lt;/p&gt;";
      echo "&lt;/div&gt;";
  echo "&lt;/div&gt;";
  
  ?&gt;
  </code></pre>
  
  <p>The stylesheet modal.css works and is included through dbconnect.php and contains:</p>
  
  <p>modal.css</p>
  
  <pre><code>#overlay {
       visibility: hidden;
       position: absolute;
       left: 0px;
       top: 0px;
       width:100%;
       height:100%;
       text-align:center;
       z-index: 1000;
  }
  
  #overlay div {
       width:300px;
       margin: 100px auto;
       background-color: #fff;
       border:1px solid #000;
       padding:15px;
       text-align:center;
  }
  </code></pre>
  
  <p>Hope anyone can help, thanks and with kind regards, Paul</p>