liontas Posted October 22, 2016 Share Posted October 22, 2016 Hi guys I have this CMS table and i want when i check a checkbox (as refers to an id) to send value to database field as "checked".Because i tried a lot and i can't find solution is there any way to fix this? Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted October 22, 2016 Share Posted October 22, 2016 None of us has psychic powers, so if you want help with code, you need to show that code (I mean the relevant parts, please don't upload your entire application). Quote Link to comment Share on other sites More sharing options...
liontas Posted October 23, 2016 Author Share Posted October 23, 2016 Here is the code.The problem is that when i check the checkbox automatically unchecked and I am try to input the values of checkboxes to datable without submitting via button. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Lumino - Tables</title> <link href="css/bootstrap.min.css" rel="stylesheet"> <link href="css/datepicker3.css" rel="stylesheet"> <link href="css/bootstrap-table.css" rel="stylesheet"> <link href="css/styles.css" rel="stylesheet"> <!--Icons--> <script src="js/lumino.glyphs.js"></script> <!--[if lt IE 9]> <script src="js/html5shiv.js"></script> <script src="js/respond.min.js"></script> <![endif]--> </head> <body> <!--Header--> <?php include 'includes/header.php'; include '../main_includes/connect_db.php'; include 'includes/functions.php'; ?> <!--end Header--> <!-- .SIDEBAR --> <?php include 'includes/sidebar.php'; ?> <!--/.sidebar--> <div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main"> <div class="row"> <ol class="breadcrumb"> <li><a href="#"><svg class="glyph stroked home"><use xlink:href="#stroked-home"></use></svg></a></li> <li class="active">Icons</li> </ol> </div><!--/.row--> <div class="row"> <div class="col-lg-12"> <h1 class="page-header">Tables</h1> </div> </div><!--/.row--> </div> <form action="" method="post"> <table class="table table-bordered table-hover" id="pinakas"> <thead> <tr> <th class="titlos"><input style="margin-left: 3px;" type="checkbox" name="checkboxAllBoxes" id="checkboxAllBoxes "></th> <th class="titlos">POST_ID</th> <th class="titlos">ΚΑΤΗΓΟΡΙΑ</th> <th class="titlos">ΤΙΤΛΟΣ</th> <th class="titlos">ΚΕΙΜΕΝΟ</th> <th class="titlos">FILE</th> <th class="titlos">ΕΚΔΟΤΗΣ</th> <th class="titlos">ΗΜΕΡ.</th> <th class="titlos">UPDATE</th> <th class="titlos">DELETE</th> </tr> </thead> <?php global $connect; $query="SELECT * FROM posts ORDER BY post_date DESC "; $select_posts= mysqli_query($connect, $query); while($row= mysqli_fetch_assoc($select_posts)) { $post_id=$row['post_id']; $post_cat_title=$row['post_cat_title']; $post_title=$row['post_title']; $post_keimeno= substr($row['post_keimeno'], 0, 60); $post_publisher=$row['post_publisher']; $post_image=$row['post_image']; $post_date=$row['post_date']; $post_check=$row['post_check']; echo "<tr>";?> <td><input type='checkbox' name="checkbox" id="<?php echo $post_id; ?>" value="txt" onchange="check(this);"></td>; <?php echo "<td class='keli'><strong>$post_id</td>"; echo "<td class='keli'>$post_cat_title</td>"; echo "<td class='keli'>$post_title</td>"; echo "<td class='keli'>$post_keimeno</td>"; echo "<td><img src='../images/$post_image' height='50' witdth='50'></td>"; echo "<td class='keli'>$post_publisher</td>"; echo "<td class='keli'>$post_date</td>"; ?> <td><a href="tables.php?source=tables&update=<?php echo $post_id; ?>">UPDATE</a></td> <td><a href="tables.php?source=tables&delete=<?php echo $post_id; ?>">Delete</a></td> </tr> <?php } ?> </table> </form> <div class="button"> <!--<button class="koumpi" type="submit" name="submit">SUBMIT</button>--> <button type="submit" name="delete"class="btn btn-primary">Delete</button> <button type="submit" class="btn btn-primary" name="update" style="background-color: green;">UPDATE</button> <button type="submit" class="btn btn-primary">Submit Button</button> </div> <!--/.row--> <!--/.main--> <script src="js/jquery-1.11.1.min.js"></script> <script src="js/bootstrap.min.js"></script> <script src="js/chart.min.js"></script> <script src="js/chart-data.js"></script> <script src="js/easypiechart.js"></script> <script src="js/easypiechart-data.js"></script> <script src="js/bootstrap-datepicker.js"></script> <script src="js/bootstrap-table.js"></script> <script> function check(ch){ if(ch.checked){ window.location.href = "tables.php?source=tables&checkbox="+ch.id+"&value=checked"; //windows.location.replace("http://yahoo.com"); } else{ window.location.href = "tables.php?source=tables&checkbox="+ch.id+"&value=unchecked"; } } </script> <!--/.main--> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.