Why is my modal not populating all my data

61 Views Asked by At

I am new to Bootstrap modals and trying to figure out where I went wrong.

I currently have this piece of code that will display a data table. The first column of the data table has a link to a modal. Upon clicking on the link, the modal displays all my information that I am requesting it to show. At the top of the modal I have an edit button that will allow the user to edit the information. When this modal loads it doesn't load of my of my columns from my database. Below is the modal and column that is not loading:

           <div class="col-2 inputRow">
                Description:
            </div>
            <div class="col-10 inputRow">
                <input class="createInput edit_description" id="edit_description" maxlength="100">
            </div>

Below is where how my data is being loaded onto my modal:

/**
 * Second check to make sure information is most current
 */
function openEditModal(){
  email = CURRENT_USER['email'];
  $.ajax({
   url: './ajax/getData.ajax.php',
   type: 'post',
   data: {
     "getUser": email,
   },
   dataType: 'json',
   success: function(response) {
     //Check for timeout
     ajaxTimeoutCheck(response);
     loadEditUser(response);

   }
  });
}

/**
 * Fills in modal to show selected users information
 */
var currentUser;
function loadEditUser(user){
  var currentUser = user;
  console.log(user);
  for (var key in user) {
    if(key != 'uid' && key != 'user' && key != 'updatedby' && key != 'updated' && key != 'global'){
      if(key == "admin"){
            if(user[key] == 1){
              document.getElementById("edit_" + key).checked = true;
            } else {
              document.getElementById("edit_" + key).checked = false;
            }
      } else if (key == "approver"){
        if(user[key] == 1){
          document.getElementById("edit_" + key).checked = true;
        } else {
          document.getElementById("edit_" + key).checked = false;
        }
      } else if(key == "department"){
        document.getElementById("edit_department").value = user[key];
     /*
      * This Section Here Is Not Responsing
      */
      } else if(key == "description"){
        document.getElementById("edit_description").value = user[key];
      } else {
        document.getElementById("edit_" + key).innerHTML = user[key];
      }
    }
  }
  document.getElementById('edit_changeAlt').checked = false;
  removeAlternateEdit();
  $("#editModal").modal();
}

My query for the getData.ajax.php file is just:

SELECT * FROM users WHERE email=$email

As you can see I have a console,log() within my code. This actually returns all my information, including the description column but when I click on the modal to load. It will leave description blank. Am I missing something here? Or is my code broken somewhere else that could be causing this?

0

There are 0 best solutions below