title: Why I get Uncaught ReferenceError: Delete is not defined at HTMLButtonElement.onclick IF IS already defined?
body: <p>I'm just creating a onclick function called <code>Delete()</code> but I don't know why, I get <code>Detele()</code> is not defined, but of it is.</p>
  <p>My onClick function is in my button:</p>
  <pre><code>$data-&gt;acción = &quot;&lt;div class='text-center'&gt;&lt;div class='btn-group'&gt;&lt;button id='modificar_$data-&gt;id' class='btn btn-primary btn-sm btnEditar' value='edit'&gt;&lt;i class='material-icons'&gt;edit&lt;/i&gt;&lt;/button&gt;&lt;button onclick='Delete($data-&gt;id, $tableName, $field)' class='btn btn-danger btn-sm btnBorrar'&gt;&lt;i class='material-icons' value='delete'&gt;delete&lt;/i&gt;&lt;/button&gt;&lt;/div&gt;&lt;/div&gt;&quot;; 
  </code></pre>
  <p>And my function:</p>
  <pre><code>function Delete(id, tableName, field){
      //$.post(&quot;&lt;?=SITE_URL_ADMIN?&gt;/alexcrudgenerator/res/?action=deleteRegistro&amp;tabla=&quot; + tabla + &quot;&amp;nombre_campo=&quot; + campo + &quot;&amp;id=&quot; + id, function(data){
      $.post(&quot;&lt;?=SITE_URL_ADMIN?&gt;/alexcrudgenerator/crud/res/&quot;, {
          action: &quot;deleteRegistro&quot;,
          id: id,
          tableName: tableName,
          field: field
          }, function (data, status) {
  
          if (confirm(&quot;¿Estás seguro que deseas borrar el registro?&quot;) == true) {
              if (status === 'error') {
                  console.log(&quot;Not deleted&quot;); // For debugging purpose
              } else if (status === 'success') {
                  console.log(&quot;Deleted successfully&quot;);                                
              }
          }
          else {
              return false;
          }
      });
  }
  </code></pre>
  <p>This is my full code:</p>
  <pre><code>&lt;?php
  
  use GuzzleHttp\json_decode;
  include_once(DIR_PLUGINS.'/alexcrudgenerator/main.php');
  
      $test = new GenerateCrud($_POST['tableName'], $_POST['id'], $_POST['tableFields']);
      
      if ($_GET['action']){
          print_a($_GET['action']);
      }
  
      switch($_POST['action']){
          
          case 'datosTabla': // OK.
              
              //print_r($_POST['action']);
              $res = json_decode($_POST['datos']);
              echo json_encode($res, JSON_UNESCAPED_UNICODE);
              
              break;
          
          case 'deleteRegistro':
              
              $id = $_POST['id']; // Quiero obtener estas variables que he enviado desde la función Delete();
              $tableName = $_POST['tableName']; // Quiero obtener estas variables que he enviado desde la función Delete();
              $field = $_POST['field']; // Quiero obtener estas variables que he enviado desde la función Delete();
              
              break;
              
          case 'showtable': // OK.
  
              $res = getEntireTable($_POST['tableName'], $_POST['id'], $_POST['tableFields']);
              $tableName = $_POST['tableName'];
              
              $field = json_decode($_POST['tableFields'],1)[0];
              //print_r($tableName);
              //print_r('&lt;br&gt;');
              //print_r($campo);
              
              foreach ($res as $data){                
                  $data-&gt;acción = &quot;&lt;div class='text-center'&gt;&lt;div class='btn-group'&gt;&lt;button id='modificar_$data-&gt;id' class='btn btn-primary btn-sm btnEditar' value='edit'&gt;&lt;i class='material-icons'&gt;edit&lt;/i&gt;&lt;/button&gt;&lt;button onclick='Delete($data-&gt;id, $tableName, $field)' class='btn btn-danger btn-sm btnBorrar'&gt;&lt;i class='material-icons' value='delete'&gt;delete&lt;/i&gt;&lt;/button&gt;&lt;/div&gt;&lt;/div&gt;&quot;; 
                  $resultados['data'][] = $data;
              }           
              
              $resultados = json_encode($resultados); // 7 PROPIEDADES
              
              foreach(json_decode($_POST['tableFields']) as $columnsDB){
                  $fields[] = array('data'=&gt;$columnsDB);
              }
  
              $fields[]['data'] = 'acción';
              $fields = json_encode($fields);
              
  ?&gt;
              &lt;head&gt;
                  &lt;link href=&quot;https://fonts.googleapis.com/icon?family=Material+Icons&quot; rel=&quot;stylesheet&quot;&gt;
              &lt;/head&gt;
              
              &lt;div class=&quot;container caja&quot;&gt;
                  &lt;div class=&quot;row&quot;&gt;
                      &lt;div class=&quot;col-lg-12 col-sm-12&quot;&gt;
                          &lt;div&gt;
                              &lt;table id=&quot;tablaUsuarios&quot; class=&quot;table table-striped table-bordered table-condensed hover&quot; style=&quot;width:100%&quot; &gt;
                                  &lt;thead class=&quot;text-center&quot;&gt;
                                      &lt;tr&gt;
                                          &lt;?php
                                              foreach (json_decode($_POST['tableFields']) as $columnsTH){
                                                   echo '&lt;th&gt;' . strtoupper($columnsTH) . '&lt;/th&gt;';
                                              }
                                              echo '&lt;th&gt;ACCIÓN&lt;/th&gt;';
                                          ?&gt;
                                      &lt;/tr&gt;
                                  &lt;/thead&gt;
                                  &lt;tbody&gt;
                                  &lt;/tbody&gt;
                              &lt;/table&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;script&gt;
                      
                  $(document).ready(function() {
                      var datos= &lt;?=$resultados?&gt;;
                      var dynamicColumns = &lt;?=$fields?&gt;;
                      datos = JSON.stringify(datos);
                      
                      $('#tablaUsuarios').DataTable({
                          &quot;language&quot;: {&quot;url&quot;: &quot;https://cdn.datatables.net/plug-ins/1.10.25/i18n/Spanish.json&quot;},
                          &quot;paging&quot;: true,
                          &quot;lengthChange&quot;: true,
                          &quot;searching&quot;: true,
                          &quot;info&quot;: true,
                          &quot;autoWidth&quot;: true,
                          &quot;scrollX&quot;: true,
  
                          &quot;ajax&quot;:{
                              &quot;url&quot;: '&lt;?=SITE_URL_ADMIN?&gt;/alexcrudgenerator/crud/res/',
                              &quot;method&quot;: 'POST',
                              &quot;data&quot;:{action: &quot;datosTabla&quot;, datos: datos}
                          },
  
                          &quot;columns&quot;: dynamicColumns
                      });
  
                      function Delete(id, tableName, field){
                          //$.post(&quot;&lt;?=SITE_URL_ADMIN?&gt;/alexcrudgenerator/res/?action=deleteRegistro&amp;tabla=&quot; + tabla + &quot;&amp;nombre_campo=&quot; + campo + &quot;&amp;id=&quot; + id, function(data){
                          $.post(&quot;&lt;?=SITE_URL_ADMIN?&gt;/alexcrudgenerator/crud/res/&quot;, {
                              action: &quot;deleteRegistro&quot;,
                              id: id,
                              tableName: tableName,
                              field: field
                              }, function (data, status) {
          
                              if (confirm(&quot;¿Estás seguro que deseas borrar el registro?&quot;) == true) {
                                  if (status === 'error') {
                                      console.log(&quot;Not deleted&quot;); // For debugging purpose
                                  } else if (status === 'success') {
                                      console.log(&quot;Deleted successfully&quot;);                                
                                  }
                              }
                              else {
                                  return false;
                              }
                          });
                      }
                  })
              &lt;/script&gt;
  &lt;?php
          break;      
  }
  ?&gt;
  </code></pre>
  <p><strong>EDIT:</strong>
  I get this error <code>Uncaught ReferenceError: users_test is not defined at HTMLButtonElement.onclick</code>, where <code>users_test</code> is the value of my <code>$tableName</code> and <code>tableName</code>.</p>