Guest User

Execute Query on Button Click If checkbox is Checked

a guest
Mar 24th, 2016
563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. HTML File
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="utf-8">
  6. <title>Test query</title>
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8.  
  9. <script language="JavaScript">
  10. function toggle(source) {
  11. checkboxes = document.querySelectorAll("input[name^='box[']");
  12. for(var i=0, n=checkboxes.length;i<n;i++) {
  13. checkboxes[i].checked = source.checked;
  14. }
  15. }
  16. </script>
  17. </head>
  18. <body>
  19. <table style="width: 100%; font-size: 11;">
  20. <tr>
  21.  
  22. <th>ve067</th>
  23.  
  24. <th>ve378</th>
  25.  
  26. <th>ve724</th>
  27.  
  28. <th>ve725</th>
  29.  
  30. <th>ve726</th>
  31.  
  32. <th>ve727</th>
  33.  
  34. </tr>
  35.  
  36. <tr>
  37.  
  38. <td>
  39. <form method="post" action="update.php">
  40. <input type="submit" name="update" value="Update - LoL / BoL"><br />
  41. <input type="checkbox" onClick="toggle(this)" name="All" value="All">&nbsp;Select all <br />
  42. <input type="checkbox" name="box[1]" value="ve067_LB1">&nbsp;LeagueBot 1<br>
  43. <input type="checkbox" name="box[2]" value="ve067_LB2">&nbsp;LeagueBot 2<br>
  44. <input type="checkbox" name="box[3]" value="ve067_LB3">&nbsp;LeagueBot 3<br>
  45. <input type="checkbox" name="box[4]" value="ve067_LB4">&nbsp;LeagueBot 4<br>
  46. </form>
  47. </td>
  48. </tr>
  49. </table>
  50. </body>
  51. </html>
  52.  
  53. Update.php file
  54. <?php
  55. if(isset($_POST['update'])) {
  56. if(isset($_POST['box'][1])) {
  57. echo('run your query here for box1 here');
  58. } else if(isset($_POST['box'][2])){
  59. echo('run your query here for box2 here');
  60. } else if(isset($_POST['box'][3])){
  61. echo('run your query here for box3 here');
  62. } else if(isset($_POST['box'][4])){
  63. echo('run your query here for box4 here');
  64. } else {
  65. header("location:test-query.php");
  66. }
  67. } else {
  68. header("location:test-query.php");
  69. }
Add Comment
Please, Sign In to add comment