jeudi 29 septembre 2016

Display Edit Button Upon Checked Checkbox

I have an HTML Table with the last column being a column with checkboxes. I want it be so that whenever I check the checkbox, an edit button pops up right next to the table and allows me to edit that row.

Right now, on load, the edit button is already there and when a checkbox is checked, it does nothing.

How can I fix this?

HTML/PHP code:

<html>
    <head>
        <title>Stage Rebate Master HTML Table</title>
        <link rel="stylesheet" type="text/css" href="html_master.css">
        <script type="text/javascript" src=jquery-1.8.3.js></script>
        <script src="html_master.js"></script>
    </head>
<body>

<table id="html_master">
<thead>
    <tr>
    <td>MR_ID</td>
    <td>MR_Name</td>
    <td>Buyer_ID</td>
    <td>MR_POC_N</td>
    <td>MR_POC_E</td>
    <td>MR_POC_P</td>
    <td>Select</td>
    </tr>
</thead>
<tbody>

<?php
    foreach ($dbh->query($sql) as $rows){
    ?>
    <tr>
        <td id="mr_id"><?php echo intval ($rows['MR_ID'])?></td>
        <td id="mr_name"><?php echo $rows['MR_Name']?></td>
        <td id="buyer_id"><?php echo $rows['Buyer_ID']?></td>
        <td id="poc_n"><?php echo $rows['MR_POC_N']?></td>     
        <td id="poc_e"><?php echo $rows['MR_POC_E']?></td>
        <td id="poc_p"><?php echo $rows['MR_POC_P']?></td>
        <td align="center"><input type="checkbox" name="check" value="checked"></td>
        </tr>
 <?php
  }
 ?>
</tbody>
        <input type="button" class="add" value="Add Row" onclick="addRow('html_master')">  
        <input type="button" id="edit" value="Edit" name="edit">
        <input type="button" id="delRow" value="Delete" onclick="deleteRow('html_master')">
</table>

</body>
</html>

Relative Javascript:

 $(document).ready(function() {

     var $submit = $("#edit").hide(),
         $cbs = $('input[name="check"]').click(function() {
             $submit.toggle( $cbs.is(":checked") );
         });

 });




Aucun commentaire:

Enregistrer un commentaire