Ticking Checkboxes with Edit/Delete Options

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
CoolAsCarlito
Forum Contributor
Posts: 192
Joined: Sat May 31, 2008 3:27 pm
Contact:

Ticking Checkboxes with Edit/Delete Options

Post by CoolAsCarlito »

Both sets of code are from the same file. If a user ticks one of the check boxes for one of the records in the table then selects edit then clicks the Apply button I want it to load the edit form into the content div with it passing the id variable of the selected record so that when it gets to the edit for it will be able to use that id to gather the information on that record from the database. If the user ticks a record in the table then selects delete the clicks the Apply button then I want it to delete the record from the database.

Code: Select all

<div class="listActions">
                  <form action="" method="post">
                     <label for="actionSelect">With selected items: </label>
                     <select class="select" name="actionSelect" id="actionSelect">
                        <option>Edit</option>
                        <option>Delete</option>
                     </select>
                     <button class="button small-button"><strong>Apply</strong></button>
                  </form>
               </div>

Code: Select all

<?php 
                    while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) {
                          echo '
                          <tr>
                          <td><input type=checkbox class=checkbox /></td>
                    <td>' . $row['menuname'] . '</a></td>
                          <td><a href=# id="menuitems" title="' . $row['menuname'] . ' Structure Items">Menu Items</a></td>
                    <td>' . $row['name'] . '</a></td>
                    <td class=last>' . $row['datecreated'] . '</td>
                    </tr>';
                        }
                    ?> 
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Ticking Checkboxes with Edit/Delete Options

Post by s.dot »

Put the row id in the value attribute of the checkbox form element.

Code: Select all

<input type="checkbox" class="checkbox" value="<?php echo $row['id']; ?>">
If you want to allow for multiple editing/deleting.. then something like this will work

Code: Select all

<input type="checkbox" class="checkbox" value="checkboxes[<?php echo $row['id']; ?>]">
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply