取消激活/激活按钮和功能

时间:2016-10-03 18:29:37

标签: javascript php jquery html

我有一个表,其中包含从数据库导入的信息,其中包含“编辑和取消激活”按钮。我不关心将任何这些信息写入数据库。我的问题是我怎么能有这个停用按钮,这样当点击它时,它会使行模糊,灰色等行等。停用时,除了激活按钮之外,我希望它不能被编辑被迫。

我还希望按钮在单击时切换到“激活”,这样如果我愿意,我可以重新激活表格中的行。并且最好两个按钮都会在点击时出现某种确认。

相对HTML / PHP:

<?php
    foreach ($dbh->query($sql) as $rows){
    ?>
    <tr>
        <td class="mr_id" contenteditable="false"><?php echo intval ($rows['MR_ID'])?></td>
        <td class="mr_name" contenteditable="false"><?php echo $rows['MR_Name']?></td>
        <td class="buyer_id" contenteditable="false"><?php echo $rows['Buyer_ID']?></td>
        <td class="poc_n" contenteditable="false"><?php echo $rows['MR_POC_N']?></td>     
        <td class="poc_e" contenteditable="false"><?php echo $rows['MR_POC_E']?></td>
        <td class="poc_p" contenteditable="false"><?php echo $rows['MR_POC_P']?></td>
        <td><button class="edit" name="edit">Edit</button>
        <button class="deactivate" name="deactivate">Deactivate</button></td>
    </tr>

相对Javascript:

$(document).ready(function() {
    $('.deactivate').click(function() {
        var $this = $(this);
        if ($this.html() === 'Deactivate') {
            $this.html('Activate');
            var result = confirm("Are you sure you want to deactivate this entry?");
            if (result) {
                // Code in order to deativate the row
            }
        }
    })
});

0 个答案:

没有答案