php - transfer value to entry form -


i newbie php , jquery. please me problem. have table contain data, retrieved database in php , mysql. have checkbox each row. had editted form, appear when click "edit" button after choose checkbox in table. want display current value on select boxes in editted form when click "edit". how do? below code: html:

<button type="submit" name="edit_permission" class="btn btn-app" id="edit_permission"><i class="fa fa-edit"></i> edit</button>   <div class="entry-form" id="newdb-entryform">       <form action="" method="post" name="new_item" class="form-inline" id="new_item">             <p >add permission </p>                 <select id="newlevel" name="newlevel">                     <option value="">choose level</option>                     <?php                         $sql="select level                                level";                         $result=mysqli_query($conn,$sql) or die(mysqli_error($conn));                         while($row=mysqli_fetch_assoc($result)){                         echo "<option value='$row[level]'";                         $temp='';                         if(isset($_post['newlevel'])) { $temp=$_post['newlevel'];}                         if($temp == $row['level']) { echo "selected='selected'";}                          echo ">$row[level]</option>";                         }                     ?>                 </select><span class="error">*</span>                 <select id="newdatabase" name="newdatabase">                     <option value="">choose system</option>                     <?php                         $sql="select `database` `database`";                         $result=mysqli_query($conn,$sql) or die(mysqli_error($conn));                         while($row=mysqli_fetch_assoc($result)){                         echo "<option value='$row[database]'";                         $temp='';                         if(isset($_post['newdatabase'])) { $temp=$_post['newdatabase'];}                         if($temp == $row['database']) { echo "selected='selected'";}                          echo ">$row[database]</option>";                         }                     ?>                 </select><span class="error">*</span>              <input type="hidden" name="id_edit" id="id_edit">             <input type="submit" value="save" name="save" id="save" />              <input type="button" value="cancel" name="cancelupload" id="cancel"/>       </form>   </div>     

jquery:

$("#edit_permission").click(function(){          if ($("#user_form input:checkbox:checked").length==1){             $('#newdb-entryform p').text('update permission');             $('#dbname').attr("placeholder", "input new database");              vals = $('input[type="checkbox"]:checked').map(function() {                 return this.value;             }).get().join(',');             console.log(vals);             $('#id_db').val(vals);             $("#newdb-entryform").fadein("fast");                return false;         }         else{             $("#text-danger-message").text('choose 1 item edit!');                 $("#danger-alert").fadeto(4000,50).fadeout(500, function(){                     $("#danger-alert").alert('close');                 });                  return false;         }      });  

please me. thank in advanced.

see example.. useful ?..

1 ) https://editor.datatables.net/examples/api/checkbox.html 2 ) https://editor.datatables.net/examples/inline-editing/simple


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -